我需要 cin "name" 上的 endl,因为输入 "name" 上可能有 2 个单词
cout << "Enter your name: ";
cin >> name;
cout << "Enter your student ID: ";
cin >> StuID;
cout << endl << "Please enter four number.";
cout << endl << "Enter the 1st number: ";
cin >> FN;
cout << "Enter the 2nd number: ";
cin >> SN;
cout << "Enter the 3rd number: ";
cin >> TN;
cout << "Enter the 4th number: ";
cin >> FourthN;
total = FN + SN + TN + FourthN;
avg = total / 4;
cout << endl <<"---------------------------------Output----------------------------------" << endl << endl;
cout << "Student Name: " << name << endl;
cout << "Student ID: " << StuID << endl;
cout << "Total: " << FN <<" + " << SN << " + " << TN << " + " << FourthN << " = " << total << endl;
cout << "Average Number: " << avg;
cout << endl << endl <<"---------------------------------Output----------------------------------" << endl << endl;
return 0;
不知何故,编译器只是跳转到“输入第一个数字”行,并没有运行学生证输入的编码行。