編程題目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);
}