Language: C++
#include <iostream>
using namespace std;
long long int Mod(long long int a, long long int b, long long int c) {
if(b == 0) return 1;
if(b % 2 == 1) return a * Mod(a*a % c, b/2, c) % c;
else return Mod(a*a % c, b/2, c) % c;
}
int main(int argc, char *argv[]) {
long long int k, N, m;
cout<< "k: " ;
cin >> k ;
cout<< "N: ";
cin>> N ;
cout<< "m: ";
cin>> m ;
cout << k << "^" << N << " mod " << m << "=" << Mod(k, N, m) << endl;
return 0;
}
想問說怎麼用argc argv在規定的command format上跑?
這裡的command format是 /a.out k N m
爬了一些文,但還是看不懂該如何處理
所以想請問各位該如何解決?
謝謝