C++ 有没有办法结束cin?
我需要在cin“名称”上的endl,因为输入“名称”上可能有2个单词C++ 有没有办法结束cin?,c++,cin,endl,C++,Cin,Endl,我需要在cin“名称”上的endl,因为输入“名称”上可能有2个单词 cout>name; cout>StuID; cout-TN; 不能>第四; 总数=FN+SN+TN+FourthN; 平均值=总数/4; 如果您必须使用std::getline()函数,请检查。否则,输入的姓氏将被放入StuID变量。尝试: 字符串全名; 看起来你想要这个:看起来你可能想要。 cout << "Enter your name: "; cin >>
cout>name;
cout>StuID;
cout-TN;
不能>第四;
总数=FN+SN+TN+FourthN;
平均值=总数/4;
如果您必须使用std::getline()
函数,请检查。否则,输入的姓氏将被放入StuID
变量。尝试:
字符串全名;
看起来你想要这个:看起来你可能想要。
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;