编程题目if
A. 在c语言里,用if语句编写一个程序,题目如下
#include
main()
{
int
s;
float
gongzi;
do{
printf("请输入工资:
");
scanf("%d",&s);
fflush(stdin);
if(s
<
1000)
{
printf("您的税后工资为:
%d\n您无需缴税;\n",s);
}
else
if(s
>=
1000
&&
s
<
2000)
{
gongzi
=
(float)s
*
0.95;
printf("您缴税金额为:%f,",
(float)s
*
0.05);
printf("您的税后工资为:
%f\n",gongzi);
}
else
if(s
>=
2000
&&
s
<
3000)
{
gongzi
=
(float)s
*
0.92;
printf("您缴税金额为:%f,",
(float)s
*
0.08);
printf("您的税后工资为:
%f\n",gongzi);
}
else
if(s
>=
3000
&&
s
<
5000)
{
gongzi
=
(float)s
*
0.9;
printf("您缴税金额为:%f,",
(float)s
*
0.1);
printf("您的税后工资为:
%f\n",gongzi);
}
else
if(s
>=
5000)
{
gongzi
=
(float)s
*
0.85;
printf("您缴税金额为:%f,",
(float)s
*
0.15);
printf("您的税后工资为:
%f\n",gongzi);
}
}while(s);/*输入工资为0结束*/
}
B. c语言编程题
#include<歼宏stdio.h>
void main()
{
int max,min,sum,i,score[10];
printf("输入数据:");
for(i=0;i<判亩10;i++)
scanf("%d",&score[i]);
sum = max = min = score[0];
for(i=1; i<10; i++)
{
if(max<掘改森score[i])max = score[i];
if(min>score[i])min = score[i];
sum =sum+score[i];
}
printf("%.2f\n", (sum-min-max)/8.0);
}