Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/127.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 有没有办法结束cin?_C++_Cin_Endl - Fatal编程技术网

C++ 有没有办法结束cin?

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 >>

我需要在cin“名称”上的endl,因为输入“名称”上可能有2个单词

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;