摘要:
#include #include using namespace std;struct CandyBar{//string kind;char kind[20];float weight;double calory;};void Display(CandyBar ca,int n){ cout>size;cin.get();CandyBar *ca=new CandyBar[size];//getline(cin,ca[0].kind);cin.get(ca[0].kind,20).get();ca[0].weight=200;ca[0].calory=100;//getline(ci 阅读全文
摘要:
#include using namespace std;const int Size=20;struct Pizza{char company[Size];double diameter;double weight;};int main(){Pizza *piz=new Pizza;//使用new创建动态结构cout>piz->diameter;cin.get();//读取下一个字符coutcompany,Size);//cin.get();cout>piz->weight;coutdiametercompanyweight<<endl;system(&q 阅读全文
摘要:
#include using namespace std;struct Pizza{char company[50];float diameter;float weight;};int main(){Pizza piz;cout>piz.diameter;cout>piz.weight;cout<<"The weight of its pizza is: "<<piz.weight<<endl;system("pause");return 0;} 阅读全文
摘要:
#include using namespace std;struct CandyBar{char kind[20];float weight;int calory;};void Display(CandyBar ca,int n){ cout<<"The kind of ca["<<n<<"] is: "<<ca.kind<<endl;cout<<"The weight of ca["<<n<<"] is: "< 阅读全文
摘要:
#include using namespace std;struct CandyBar{char kind[20];float weight;int calory;};int main(){CandyBar snack={"Mocha Munch",2.3,350};cout<<"The kind of snack is: "<<snack.kind<<endl;cout<<"The weight of snack is: "<<snack.weight<<en 阅读全文
摘要:
#include #include using namespace std;int main(){string fname;string lname;string name;cout<<"Enter your first name: ";getline(cin,fname);cout<<"Enter your last name: ";getline(cin,lname);name=lname+", "+fname;cout<<"Here's the information in 阅读全文
摘要:
#include #include using namespace std;int main(){char fname[20];char lname[20];char name[45];cout<<"Enter your first name: ";cin.getline(fname,20);cout<<"Enter your last name: ";cin.getline(lname,20);strcpy(name,lname);strcat(name,", ");strcat(name,fname);co 阅读全文
摘要:
#include #include int main(){using namespace std;string name;string dessert;coutEnter your favorite dessert: Radish TorteI have some delicious Radish Torte for you, Han Meimei.对于存在的getline需要输入两次Enter键才能输出后面一句的问题,解决办法:修改string头文件,找到 else if(_Tr::eq((_E)_C,_D)) {_Chg=true; //_I.rdbuf()->snextc();/* 阅读全文
摘要:
#include //#include using namespace std;struct stu{char fname[10];//这里若用string fnamechar lname[10];//同样这里若用string lnamechar grade;int age;};int main(){stu stu1;cout>stu1.grade;cout>stu1.age;cout<<"Name: "<<stu1.fname<<", "<<stu1.lname<<endl;cou 阅读全文