我现在使用c++ primer plus第四版学习c++编程,在第四章的编程有这样一题:编程一个程序,请求并显示信息所示。注意,改程序应该接受的名字包含多个单词。另外,程序将向下调整成绩,即向上调一个字母。假设用户请求A,B或C,所以不必担心D和F之间的空档。
What is your first name? Betty Sue
What is your last name? Yew
What letter grade do you deserve? B
Name: Yew,Betty Sue
Grade:C
Age:22
以下是我编的代码,可以实现,但我想知道有没有办法可以用数组处理用户输入的成绩,希望各位指点一下,谢谢!
#include
using namespace std;
int main(){
char f_name[20];
char l_name[20];
char i;
int age;
cout<<"whta is your first name?";
cin.getline(f_name,20);
cout<<"what is your last name?";
cin.getline(l_name,20);
cout<<"what letter grade do you deserve?";
cin>>i;
cout<<"what is your age?";
cin>>age;
cout<<"Name: "< cout<<"Grade: "< cout<<"Age: "<
return 0;
}
--------------------next---------------------
阅读(1293) | 评论(0) | 转发(0) |