标签:
猜数字
#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;
}
三角形
#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;
}
个人所个税
#include <stdio.h>
int
main ( )
{
float
salary,tax=0,afterTaxIncome=0,i;
int
t;
printf(
"请输入您本月的收入总额(元):"
);
scanf(
"%f"
, &salary);
i=salary-3500;
{
if
(i<=0)
t=0;
else
if
(i<=1500)
t=1;
else
if
(i>1500 && i<=4500)
t=2;
else
if
(i>4500 && i<=9000)
t=3;
else
if
(i>9000 && i<=35000)
t=4;
else
if
(i>35000 && i<=55000)
t=5;
else
if
(i>55000 && i<=80000)
t=6;
else
if
(i<80000)
t=7;
}
switch
(t)
{
case
1:printf(
"tax=(s-3500)*0.03 TaxIncome=s-tax\n"
);
break
;
case
2:printf(
"tax=(s-3500)*0.1 TaxIncome=s-tax\n"
);
break
;
case
3: printf(
"tax=(s-3500)*0.2 TaxIncome=s-tax\n"
);
break
;
case
4:printf(
"tax=(s-3500)*0.25 TaxIncome=s-tax\n"
);
break
;
case
5:printf(
"tax=(s-3500)*0.3 TaxIncome=s-tax\n"
);
break
;
case
6: printf(
"tax=(s-3500)*0.35 TaxIncome=s-tax\n"
);
break
;
default
:printf(
"tax=(s-3500)*0.45 TaxIncome=s-tax\n"
);
break
;
}
afterTaxIncome=salary-tax;
printf(
"您本月应缴个人所和税 %.2f 元,税后收入是 %.2f 元。\n"
, tax, afterTaxIncome);
return
0;
标签:
原文地址:http://www.cnblogs.com/zzc214/p/5951811.html