作为输入,我有一行:
2 6 7 5 1 2 3 4 5
A a b B c d e f g
其中A - 整数,有多少个数字Array1
,然后a b
- 中的数字Array1
,然后B - 整数,有多少个数字Array2
,c d e f g
- 中的数字Array2
我写了这段代码:
scanf("%d", &Alen); // read Array1 len
int posA[Alen];
for (i = 0; i < Alen; i++){
scanf("%d", &posA[i]);//read Array1 numbers
}
scanf("%d", &Blen);//read Array2 len
int posB[Blen];
for (i = 0; i < Blen; i++){//read Array2 numbers
scanf("%d", &posB[i]);
}
但它太慢了(最慢,比我的程序,用这个数组做一些事情),所以可能有另一种方法来扫描这个数组,并快速执行此操作?