C/C++初学者 - 语法题库

首页    重新查询   

章节: 《第7章 Switch语句》
一星为基础题,五星为工业应用题;星级越高,难度越大;不一定要做完所有题,差不多就可以进入下一章,反复迭代
共 2 条结果 ( 每页 10条 )
 
章节: 第7章 Switch语句
难度: ★ 1
题目:
case 判定
描述:
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d,m;
	c=5;d=18;
	cin>>a>>b;
	if (a*b>c*d)
		m=c*d;
	else
		m=a*b;
	switch(m/10)
	{
		case 1:
		case 2:
		case 3:cout<<"one"<<endl;break;
		case 4:
		case 5:
		case 6:cout<<"two"<<endl;break;
		case 7:
		case 8:
		case 9:cout<<"three"<<endl;break;
		default:cout<<"five"<<endl;		
	}	
	return 0;
}
输入:  10  2
输出: __________
输入:  20   9
输出: __________
  

    
  
输入:  10  2
输出:  one
输入:  20   9
输出:  three

章节: 第7章 Switch语句
难度: ★ 1
题目:
交税
描述:
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{ 
	double a,b;	
	cin>>a;	
	switch((int)a/5000)
	{
		case 0:b=0;break;
		case 1:b=a*0.03;break;
		case 2:b=a*0.05;break;	
	}
	printf("%.2lf",b);	
	return 0;
}
输入:6000
输出:__________
输入:11000
输出:__________
输入: 3000
输出:__________
  

    
  
输出:    180.00
输入:11000
输出:     550.00
输入: 3000
输出:      0.00