标签:
#include <stdio.h> #include <stdlib.h> #include <time.h> int main(void){ 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"); else printf("您输入的数字不合法,请重新输入!\n"); } while(yourNumber!=myNumber); if(count<3) { printf("您猜了%d次\n",count); printf("天才!\n"); } if(count>=3&&count<8) { printf("您猜了%d次\n",count); printf("智力正常!\n"); } if(count>8) { printf("您猜了%d次\n",count); printf("笨!\n"); } printf("继续请按Y/y,退出请按N/n"); getchar(); c=getchar(); system("cls"); } while(c==‘Y‘||c==‘y‘); return 0; }
2
#include <stdio.h> #include <math.h> int main() { float a,b,c,p,s,D; printf("请输入三个边长:\n"); scanf("%f%f%f",&a,&b,&c); if(a+b>c&&a+c>b&&b+c>a) { printf("能够构成三角形\n"); } else{ printf("不能构成三角形\n"); } p=(a+b+c)/2; s=sqrt(p*(p-a)*(p-b)*(p-c)); printf("面积为:%f\n",s); D=(a+b+c); printf("周长为:%f\n",D); return 0; }
3
#include <stdio.h> int main ( ) { double dSalary,dTax=0,dNetIncome=0; double dValue; printf("请输入您本月的收入总额(元):"); scanf("%lf", &dSalary); dValue=dSalary-3500; if(dValue<=0.0) dTax=0.0; else { if (dValue<=1500) dTax=dValue*0.03-0.0; else if(dValue<=4500) dTax=dValue*0.10-105.0; else if(dValue<=9000) dTax=dValue*0.20-555.0; else if(dValue<=35000) dTax=dValue*0.25-1005.0; else if(dValue<=55000) dTax=dValue*0.30-2755.0; else if(dValue<=80000) dTax=dValue*0.35-5505.0; else dTax=dValue*0.45-13505.0; } dNetIncome=dSalary-dTax; printf("您本月应缴个人所和税 %.2lf 元,税后收入是 %.2lf 元。\n", dTax, dNetIncome); return 0; }
标签:
原文地址:http://www.cnblogs.com/ws562304130/p/5947431.html