1.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a=12,b=3;
float x=18.5,y=4.6;
printf("%f\n",(float)(a*b)/2);
printf("%d\n",(int)x%(int)y);
}
18.000000
2
2.
#include <stdio.h>
#include <stdlib.h>int main()
{
int x=32,y=81,p,q;
p=x++;
q=--y;
printf("%d%d\n",p,q);
printf("%d%d\n",x,y);
}
3280
3380
3.
#include <math.h>
#include <stdio.h>
int main()
{
int x,a,b,c,y;
printf("请输入一个三位数:");
scanf("%d",&x);
a=x/100;
b=(x-100*a)/10;
c=x%10;
y=c*100+b*10+a;
printf("y=%d\n",y);
}
4. #include <stdio.h>
#include <stdlib.h>
int main(void)
{
float a=0.0225,x,y,n;
scanf("%f",&x); //输入本金
scanf("%f",&n); //输入存储的年份
y=x+(x*n*a);
printf("%f",y);
return 0;
}
5.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int a,b,c,h,x1,x2;
printf("请输入方程系数a,b,c:\n");
while(1)
{
{
int a,b,c,h,x1,x2;
printf("请输入方程系数a,b,c:\n");
while(1)
{
scanf("%d%d%d",&a,&b,&c);
h=b*b-4*a*c;
x1=(-b+sqrt(h))/(2*a);
x2=(-b-sqrt(h))/(2*a);
if (h>=0);
printf("得到方程根\n x1=%d\n x2=%d",x1,x2);
if (h<0);
printf("\n请输入新的方程系数a,b,c:\n");
}
}
h=b*b-4*a*c;
x1=(-b+sqrt(h))/(2*a);
x2=(-b-sqrt(h))/(2*a);
if (h>=0);
printf("得到方程根\n x1=%d\n x2=%d",x1,x2);
if (h<0);
printf("\n请输入新的方程系数a,b,c:\n");
}
}