这是本人搜录的,绝对有用。
源代码:
#include<stdio.h>
#include<math.h>
main()
{
int year=2;
float rate=0.1,money=1000;
float futureMoney;
futureMoney=money*pow((1+rate),year);
printf("%10.2f",futureMoney);
system("pause");
}
实验2-5:
输入华氏温度,输出对应的摄氏温度。计算公式如下:
c = 5 * ( f - 32) / 9
其中,c表示摄氏温度,f表示华氏温度
源代码:
#include<stdio.h>
main()
{
int c,f;
scanf("%d",&f);
c = 5 * ( f - 32) / 9;
printf("%d",c);
system("pause");
}
实验3-1:
编写一个程序完成输入一个整数,输出它的符号
源代码:
#include<stdio.h>
main()
{
int i;
scanf("%d",&i);
if(i>0)
printf("+");
else
printf("-");
system("pause");
}
实验3-2: