[问题] command format

楼主: triumphant10 (yu12510)   2019-05-16 22:56:44
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
爬了一些文,但还是看不懂该如何处理
所以想请问各位该如何解决?
谢谢
作者: RishYang (Rish)   2019-05-16 23:38:00
作者: TitanEric (泰坦)   2019-05-17 00:04:00
利用argv对空白切token 记得执行档名是第一个
作者: RishYang (Rish)   2019-05-17 00:09:00
假设这样执行: ./a.exe AA BB CCargc=4 *argv[0]="./a.exe" *argv[1] = "AA"*argv[2] = "BB" *argv[3] = "CC"
作者: dces4212 (flawless)   2019-05-20 04:51:00
搞懂指标这个想起来比较顺

Links booklink

Contact Us: admin [ a t ] ucptt.com