<分区>
我的输入是这样的
4
1 2
3 4
5 6
7 8
我想做的是把它分成两组。 How to split a full=number into two groups according to their position(even or odd) 我在这里问过。我认为答案是正确的。当我与男孩[3]核对时; 好像有问题。这是代码,我找不到错误?应该输出8
#include<fstream>
#include<iostream>
using namespace std;
int main(){
ifstream ifs("Q3_IN.txt");
int g;
ifs>>g;
int boy[g];int girl[g];
int a =0; int b = 0;
for(int i=0;i<g;i++){
if(i%2) ifs>>boy[b++];
else ifs>>girl[a++];
}
cout<<boy[3];
system("pause");
return 0;}