我有循环谁不工作
它只显示第一个cout输入1个学生信息
或以太它跳过循环并在其下做所有事情
你能帮忙吗?
int x = 1; while (x <= 10) { ++x; if (x = 1) { cout << "enter 1 student info"; cin >> name >> first >> second >> final>>id; } else if (x = 2) { cout << "enter 2 student info"; cin >> name1 >> first1 >> second1 >> final1 >> id1; } else if (x = 3) { cout << "enter 3 student info"; cin >> name2 >> first2 >> second2 >> final2 >> id2; } else if (x = 4) { cout << "enter 4 student info"; cin >> name3 >> first3 >> second3 >> final3 >> id3; } }
...
for (int x = 1; x <= 9; x++) { if (x = 1) { cout << "enter 1 student info"; cin >> name >> first >> second >> final>>id; } if (x = 2) { cout << "enter 2 student info"; cin >> name1 >> first1 >> second1 >> final1 >> id1; } if (x = 3) { cout << "enter 3 student info"; cin >> name2 >> first2 >> second2 >> final2 >> id2; } if (x = 4) { cout << "enter 4 student info"; cin >> name3 >> first3 >> second3 >> final3 >> id3; } }
小智.. 6
我只是告诉你第一个错误,如果你在哪里使用=
(赋值运算符)而不是==
(等于运算符)
int x=1; while (x<=10) {++x; if(x==1)
有关更多信息,请查看cpp参考或wikipidia
我只是告诉你第一个错误,如果你在哪里使用=
(赋值运算符)而不是==
(等于运算符)
int x=1; while (x<=10) {++x; if(x==1)
有关更多信息,请查看cpp参考或wikipidia