摘要: #include using namespace std;const int MAXSIZE=100;int main(){int a[MAXSIZE];int sum=0;for(int i=0;i>a[i];if(a[i]==0)return 0; sum=sum+a[i];cout<<"sum= "<<sum;}system("pause");return 0;} 阅读全文
posted @ 2013-11-26 13:03 编程的爬行者 阅读(90) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std;int main(){int min,max;cout>min;cout>max;int sum=0;for(int i=min;i<=max;i++)sum+=i;cout<<"The sum from min to max: "<<sum<<endl;system("pause");return 0;} 阅读全文
posted @ 2013-11-26 12:36 编程的爬行者 阅读(104) 评论(0) 推荐(0) 编辑
摘要: #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 阅读全文
posted @ 2013-11-20 16:59 编程的爬行者 阅读(96) 评论(0) 推荐(0) 编辑
摘要: #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 阅读全文
posted @ 2013-11-20 16:06 编程的爬行者 阅读(113) 评论(0) 推荐(0) 编辑
摘要: #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;} 阅读全文
posted @ 2013-11-20 15:54 编程的爬行者 阅读(98) 评论(0) 推荐(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: "< 阅读全文
posted @ 2013-11-20 15:44 编程的爬行者 阅读(107) 评论(0) 推荐(0) 编辑
摘要: #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 阅读全文
posted @ 2013-11-20 15:27 编程的爬行者 阅读(106) 评论(0) 推荐(0) 编辑
摘要: #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 阅读全文
posted @ 2013-11-20 15:16 编程的爬行者 阅读(99) 评论(0) 推荐(0) 编辑
摘要: #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 阅读全文
posted @ 2013-11-20 15:08 编程的爬行者 阅读(97) 评论(0) 推荐(0) 编辑
摘要: #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();/* 阅读全文
posted @ 2013-11-20 10:45 编程的爬行者 阅读(171) 评论(0) 推荐(0) 编辑