比较简单的程序

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: ;
}


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值