请教两个简单的C++编程问题
/* * tp。 cpp * * Created on: 2008-11-15 * Author: T */A1:#include <iostream>using namespace std;int main(){ char c[100]; cin>>c; cout<<"length of the number is "<<strlen(c)<<endl; for(int i=strlen(c)-1;0<=i;i--){ cout<<"the "<<strlen(c)-i<<...全部
/* * tp。
cpp * * Created on: 2008-11-15 * Author: T */A1:#include <iostream>using namespace std;int main(){ char c[100]; cin>>c; cout<<"length of the number is "<<strlen(c)<<endl; for(int i=strlen(c)-1;0<=i;i--){ cout<<"the "<<strlen(c)-i<<"th number is "<<c[i]<<endl; } for(int i=strlen(c)-1;0<=i;i--) cout<<c[i]; cout<<endl; return 0;}A2:#include <iostream>using namespace std;int main(){ int i,j,s[5]; for(i=0;i<4;i++)cin>>s[i]; for(i=0;i<4;i++) for(j=0;j<4-i-1;j++) if(s[j+1]<s[j]){ s[4] = s[j]; s[j] = s[j+1]; s[j+1] = s[4]; } for(i=0;i<4;i++) cout<<s[i]<<" "; cout<<endl;}A3:怎么能办到?同校不比赛?这可能么,3个人肯定要分开,分开就一定要比赛阿我按照另外一个意思理解,同组的比赛?#include <iostream>using namespace std;int main(){ int a,b,c,x,y,z; bool t = true; for(a=1;a<=3&&t;a++) for(b=1;b<=3&&t;b++) for(c=1;c<=3&&t;c++) for(x=1;x<=3&&t;x++) for(y=1;y<=3&&t;y++) for(z=1;z<=3&&t;z++) if(a!=b && a!=c && b!=c && x!=y && x!=z && y!=z && a!=x && c!=x && c!=z){ cout<<"A: "<<a<<" ,B: "<<b<<" ,C: "<<c<<" ,X: "<<x<<" ,Y: "<<y<<" ,Z: "<<z<<endl; t = false; } return 0;}answer:A: 1 ,B: 2 ,C: 3 ,X: 2 ,Y: 3 ,Z: 1AZ一组 BX一组 CY一组。收起