2
#include<iostream>
using namespace std;
int main()
{ int a, b, c, t;
cout << "a, b, c=";
cin >> a >> b >> c;
if(a>b) { t=a; a=b; b=t; }
if(a>c) { t=a; a=c; c=t; }
if(b>c) { t=b; b=c; c=t; }
cout<< a << '\t'<< b << '\t' << c << endl;
}
3.
#include<iostream>
using namespace std;
int main()
{ double a, b, c ;
cout << "a, b, c = " ;
cin >> a >> b >> c ;
if ( a+b > c && b+c > a && c+a > b )
{ if ( a == b && b == c )
cout << "等边三角形!" << endl;
else if ( a == b || a == c || b == c )
cout << "等腰三角形!" << endl;
else cout << "一般三角形!" << endl;
}
else
cout << "不能形成三角形!" << endl ;
}
4.
#include <iostream>
using namespace std;
int main(){
int score;char grade;
cout<<""<<endl;
cin>>score;
if(score>=90) grade=‘A’;
else if(score>=80)grade=‘B’;
else if(score>=70)grade=‘C’;
else if(score>=60)grade=‘D’;
else grade=‘E’;
cout<<grade<<endl;
}
5.
#include<iostream>
using namespace std;
int main()
{ char first,second;
cout << "第一次( s,r or p ):";
cin >> first;
cout << "第二次( s,r or p ):";
cin >> second;
switch ( first )
{ case 's':
switch ( second )
{ case 's': cout << "不分胜负." << endl; goto end;
case 'r': cout << "后者胜." << endl; goto end;
case 'p': cout << "前者胜" << endl; goto end;
default : cout << "后者出错!" << endl ; goto end;
}
case 'r':
switch ( second )
{ case 's': cout << "前者胜" << endl; goto end;
case 'r': cout << "不分胜负." << endl; goto end;
case 'p': cout << "后者胜." << endl; goto end;
default : cout << "后者出错!" << endl; goto end;
}
case 'p':
switch ( second )
{ case 's': cout << "后者胜." << endl; goto end;
case 'r': cout << "前者胜" << endl; goto end;
case 'p': cout << "不分胜负." << endl; goto end;
default : cout << "后者出错r!" << endl; goto end;
}
default : cout << "前者出错!" << endl; goto end;
}
end: ;
}