#include <iostream> #include <cstdlib> int main() { using namespace std; const int arsize= 7; char name[arsize]; char dessert [arsize]; int i=0; do{ i++; cout<<"Enter your name:\n"; cin.get(name,arsize); if(i>=2) { cin.get();} cout<<"Enter your favorite dessert: \n"; cin.get(dessert,arsize); cout<<"Now I have some delicious|"<<dessert<<"|for you ,"<<name<<" .\n"; }while(i<=arsize); system("pause"); /* ************** cin.getline(name,20); cout<<"Enter your favorite dessert:\n"; cin.getline(dessert,20); cout<<"Now I have some "<<dessert<<" for "<<name<<endl; *********************/ return 0; }
运行结果测试如下:
相关分类