zoukankan      html  css  js  c++  java
  • 实验二 选择结构程序设计

    (1)

    #include <stdio.h>
    
    int main()
    {
    	char a,b,c,d,e;
    	a = getchar();
    	b = getchar();
    	c = getchar();
    	d = getchar();
    	e = getchar();
    	putchar(a);
    	putchar(b);
    	putchar(c);
    	putchar(d);
    	putchar(e);
    	putchar("\n");
    	return 0;
    }
    

     

    (2)

    #include<stdio.h>
    
    int main()
    {
    	int year,month,days;
    	month = 2;
    	printf("input the year:");
    	scanf("%d",&year);
    	if((year % 4 == 0 && year % 100 != 0)|| year % 400 == 0 && year % 100 == 0)
    	{
    		days=29;
    		printf("year:");
    		printf("%d\n",year);
    		printf("month:");
    		printf("%d\n",month);
    		printf("days:");
    		printf("%d\n",days);
    	}
    	else{
    		days=28;
            printf("year:");
    		printf("%d\n",year);
    		printf("month:");
    		printf("%d\n",month);
    		printf("days:");
    		printf("%d\n",days);
    	}
    
    return 0;
    }
    

     

    (3)

    #include<stdio.h>
    #include<math.h>
    
    int main()
    {
    	int a,b,c;
    	scanf("%d%d%d",&a,&b,&c);
    	if((a+b)>c && (a+c)>b && (b+c)>a)
    	{
    		printf("能构成三角形\n");
    
    	    if((pow(a,2)+pow(b,2)==pow(c,2)) || (pow(a,2)+pow(c,2)==pow(b,2)) || (pow(b,2)+pow(c,2)==pow(a,2)))
    		{
    			printf("直角三角形\n");
    		}
    		if((a==b)||(a==c)||(b==c))
    		{
    			if((a==b)&&(a==c)&&(b==c))
    			{
    				printf("等边三角形\n");
    			}
    			else
    			{
    				printf("等腰三角形\n");
    			}
    		}
    	}
    	else
    	{
    		printf("不能构成三角形\n");
    	}
    
    return 0;
    }
    

     

    (4)

    #include<stdio.h>
    
    int main()
    {
    	double a,rate,tax,profit;
    	printf("input a:");
    	scanf("%lf",&a);
    	if(a<500)
    	{
    		rate = 0.00;
    		tax = a * rate;
    		profit = a - tax;
    	}
    	else if(a>=500 && a<1000)
    	{
    	    rate = 0.05;
    		tax = a * rate;
    		profit = a - tax;
    	}
    	else if(a>=1000 && a<2000)
    	{
    	    rate = 0.08;
    		tax = a * rate;
    		profit = a - tax;
    	}
    	else if(a>=2000 && a<5000)
    	{
    	    rate = 0.10;
    		tax = a * rate;
    		profit = a - tax;
    	}
    	else if(a>5000)
    	{
    	    rate = 0.15;
    		tax = a * rate;
    		profit = a - tax;
    	}
    
    	printf("%lf\n%lf\n%lf\n",rate,tax,profit);
    
    return 0;
    }
    #include<stdio.h>
    
    int main()
    {
    	int c;
    	double a,rate,tax,profit;
    	printf("please enter a:");
    	scanf("%lf",&a);
    	if(a>=5000) c=10;
    	else        c=a/500;
    	switch(c)
    	{
    	case 0: rate=0.00;break;
    	case 1: rate=0.05;break;
    	case 2: 
    	case 3: rate=0.08;break;
    	case 4:
    	case 5:
    	case 6:
    	case 7:
    	case 8:
    	case 9: rate=0.10;break;
    	case 10: rate=0.15;break;
    	}
    
    	tax = a * rate;
    	profit = a - tax;
    	printf("%lf\n%lf\n%lf\n",rate,tax,profit);
    
    return 0;
    }
    

     

  • 相关阅读:
    【IIS错误】IIS各种错误
    【IIS错误
    【C#】C#操作Excel文件(转)
    【C#】语音识别
    【IIS错误】未能加载文件或程序集“AAAAA”或它的某一个依赖项。试图加载格式不正确的程序。
    【Web前端】清除css、javascript及背景图在浏览器中的缓存
    【模态窗口-Modeldialog】提交请求时禁止在新窗口打开页面的处理方法
    第八周学习进度表
    梦断代码阅读笔记01
    第二阶段冲刺第七天
  • 原文地址:https://www.cnblogs.com/P201821430044/p/10768757.html
Copyright © 2011-2022 走看看