作业

作业1
#include <stdio.h> #include <stdlib.h> #include <time.h> int main() { int mynumber,yournumber,count=0; char c; do{ srand((unsigned)time(NULL)); mynumber = (rand() % (101 - 1)) + 1; do{ printf("请输入您猜想的数值:"); scanf("%d",&yournumber); count++; if(yournumber>mynumber) printf("数字太大请您重新输入\n"); else if(yournumber<mynumber) printf("数字太小请您重新输入\n"); else if(yournumber!=mynumber) printf("您输入的数字不合法,请重新输入\n"); } while(yournumber!=mynumber); { if(count<=3) printf("天才!\n"); else if(count>3 && count<=7) printf("智力正常!\n"); else printf("笨!"); } printf("您一共猜了%d次\n",count); printf("继续请按Y/y,退出请按N/n:\n"); getchar(); c=getchar(); system("cls"); }while(c=='Y' || c=='y'); return 0; }

作业2

#include<stdio.h>
#include<math.h>
int main()
{
int a=0,b=0,c=0,z;
float s,ave;
printf("请输入三条边:\n");
scanf("%d%d%d",&a,&b,&c);
if(a+b>=c && a+c>=b && b+c>=a)
{
s=(a+b+c)*1/2.0;
ave=sqrt(s*(s-a)*(s-b)*(s-c));
printf("面积为:%f\n",ave);
z=a+b+c;
printf("周长为:%d\n",z);
}
else
printf("不能构成三角形。\n");
return 0;
}

作业3

#include <stdio.h>
int main()
{
    float a,tax=0,TaxIncome=0;
    printf("请输入您本月收入总额(元):");
    scanf("%f",&a);
    if(a<=1455)
    {
        tax=(a-3500)*0.03-0;
        TaxIncome=a-tax;
    }
    else if(a>1455 || a<=4155)
    {
        tax=(a-3500)*0.1-105;
        TaxIncome=a-tax; 
    }
    else if(a>4155 || a<=7755)
    {
        tax=(a-3500)*0.2-555;
        TaxIncome=a-tax;
    }
    else if(a<7755 || a<=27255)
    {
        tax=(a-3500)*0.25-1005;
        TaxIncome=a-tax;
    }
    else if(a>27255 || a<=41255)
    {
        tax=(a-3500)*0.3-2755;
        TaxIncome=a-tax;
    }
    else if(a>41255 || a<=57505)
    {
        tax=(a-3500)*0.35-5505;
        TaxIncome=a-tax;
    }
    else
    {
        tax=(a-3500)*0.45-13505;
        TaxIncome=a-tax;
    }
    printf("您本月应缴税为:%f\n您本月的税后收入为:%f\n",tax,TaxIncome);
    return 0;
}
#include <stdio.h>
int main()
{
    float salary,tax=0,TaxIncome=0,c;
    int a;
    printf("请输入您的工资:\n");
    scanf("%f",&salary);
    c=salary-3500;
    {
        if(c<=0)
        a=0;
        if(c<=1455)
        a=1;
        else if(c>1455&&c<=4155)
        a=2;
        else if(c>4155&&c<=7755)
        a=3;
        else if(c>7755&&c<=27255)
        a=4;
        else if(c>27255&&c<=41255)
        a=5;
        else if(c>41255&&c<=57505)
        a=6;
        else
        a=7;
    }
    switch(a)
    {
        case 1:printf("tax=(c-3500)*0.03 TaxIncome=c-tax\n");
        break;
        case 2:printf("tax=(c-3500)*0.1 TaxIncome=c-tax\n");
        break;
        case 3:printf("tax=(c-3500)*0.2 TaxIncome=c-tax\n");
        break;
        case 4:printf("tax=(c-3500)*0.25 TaxIncome=c-tax\n");
        break;
        case 5:printf("tax=(c-3500)*0.3 TaxIncome=c-tax\n");
        break;
        case 6:printf("tax=(c-3500)*0.35 TaxIncome=c-tax\n");
        break;
        default:printf("tax=(c-3500)*0.45 TaxIncome=c-tax\n");
        break;
    }
    salary=TaxIncome;
    printf("您本月应缴税:%f元\n 您本月的税后收入为:%f元\n",tax,TaxIncome);
    return 0;
} 





心得

每一次都是进步 对程序的认识与日俱增 相信在不久的将来 我一定能够达到心中的目标

 



 


  

posted @ 2016-10-12 21:32  littleTs  阅读(115)  评论(3编辑  收藏  举报