sum+=year_sale[i]; }
for(int i=0;i<3;i++)
cout< //ex.5.7 #include string name; int year; }; int main() { cout<<\ int num; (cin>>num).get(); car* ps=new car[num]; for(int i=0;i cout<<\ cout<<\ getline(cin,ps[i].name); cout<<\ (cin>>ps[i].year).get(); } cout<<\ for(int i=0;i cout< //ex.5.8 #include #include int main() { using namespace std; char word[20]; int sum=0; cout<<\ cin>>word; while(strcmp(word,\ { sum++; cin>>word; } cout<<\ return 0; } //ex.5.9 #include int main() { using namespace std; string word; int sum=0; cout<<\ cin>>word; while(word!=\ { sum++; cin>>word; } cout<<\ return 0; } //ex.5.10 #include int main() { using namespace std; cout<<\ } int num; cin>>num; for(int i=0;i for(int j=num-i;j>1;j--) for(int k=0;k<=i;++k) cout< cout<<\ cout<<\ 第六章 分支语句和逻辑运算符 //ex.6.1 #include int main() { using namespace std; char ch; cin.get(ch); while(ch!='@') { if(isdigit(ch)) cin.get(ch); else { if(islower(ch)) ch=toupper(ch); else ch=tolower(ch); cout< return 0; } //ex.6.2--数组 #include using namespace std; double sum=0,average=0; double num[10]; int i=0,total=0; double temp; while(cin>>temp&&i<10&&!isdigit(temp)) { num[i]=temp; sum+=num[i]; ++i; } if(i!=0) average=sum/i; for(int j=0;javerage) ++total; cout<<\这些数字的平均值为\ cout<<\并且共有\个数字大于平均值。\\n\ return 0; } //ex.6.2--array #include using namespace std;