摘要:
/* 输出华氏-摄氏温度转换表*/#include int main(void){ /*fahr=华氏度, celsius=摄氏度, lower=下限, upper=上限*/ int fahr,lower,upper; double celsius; printf("Enter lower:"); scanf_s("%d",&lower); printf("Enter upper:"); scanf_s("%d",&upper); printf("fahr celsius\n") 阅读全文
摘要:
/* 计算存款本息 */#include#include int main(void){ int money,year; double rate,sum; printf("Enter money:"); scanf_s("%d",&money); printf("Enter year:"); scanf_s("%d",&year); printf("Enter rate:"); scanf_s("%lf",&rate); sum=money*pow(1 阅读全文
摘要:
/* 计算二分段函数 */#includeint main(void){ double x,y; printf("Enter x(x>=0):\n"); scanf_s("%lf",&x); if(x<=15){ y=4*x/3; } else{ y=2.5*x-10.5; } printf("y=f(%f)=%.2f\n",x,y); return 0;} 阅读全文
摘要:
/* 将华氏温度转换为摄氏温度 */#includeint main(void){ /* celsius=摄氏度 fahr=华氏度 */ int celsius,fahr; fahr = 100; celsius=5*(fahr-32)/9; printf("fahr=%d,celsius=%d/n",fahr,celsius); return 0;} 阅读全文
摘要:
/* 显示两行文字 */#includeint main(void){ printf("Programming is fun.\n"); printf("And programming in C is even more fun!\n"); return 0;} 阅读全文
摘要:
/* 显示“Hello World!”*/#includeint main(void){ printf("Hello World!\n"); return 0;} 阅读全文
摘要:
#includeint main(void){ int a,b,c,d; a=250; b=38; c=2; d=a+b+c; printf("%d",d); return 0;}#includeint main(void){ int a,b,c; a=10; b=10; c=a*b; printf("%d",c); return 0;} 阅读全文
摘要:
#includeint main(void){ int n; int factorial(int n); scanf_s("%d",&n); printf("%d\n",factorial(n)); return 0;}int factorial(int n){ int i,fact=1; for(i=1;i<=n;i++) fact=fact*i; return fact;} 阅读全文
摘要:
//计算某个数x的平方y,并分别以“y = x*x”和“x*x = y”的形式输出x和y的值#includeint main(void){ int x,y; /*定义两个变量x和y*/ printf("请输入x的值:"); scanf("%d",&x); y=x*x; /*输入一个表达式*/ printf("%d=%d*%d\n",y,x,x); /*确定输出格式为y=x^2*/ printf("%d*%d=%d\n",x,x,y); /*... 阅读全文