摘要:
//输入一个整数 x,计算并输出下列分段函数 sign(x) 的值#includeint main(void){ int x,y; printf("输入x:"); scanf("%d",&x); if(x<0){ y=-1; } else if(x==0){ y=0; } //运用if的语句 else{ y=1; } printf("y=%d",y); return 0;} 阅读全文
摘要:
#include int main(void) { int i,n; double x; double fact(int n); scanf ("%d", &n); x=0; for(i=0;i<=n;i++){ x=x+fact(i); } printf("x=%.0f\n",x); return 0;}double fact(int n) { int i; double y; y=1; for(i=1;i<=n;i++){ ... 阅读全文
摘要:
#include#includeint main(void){ int n,i,power; double product; printf("Enter n:"); scanf("%d",&n); product=0; for(i=1;i<=n;i++){ power=pow(2,i); printf("%d",power); product=product+power; } printf("product=%.0f\n",product); return 0;} 阅读全文
摘要:
#include #include int main(void) { int year; double loan,money,my,rate; scanf("%Lf",&loan); scanf("%Lf",&rate); printf("year money\n"); for(year=5;year<=30;year++){ my=pow(1+rate,12*year); money=loan*rate*my/(my-1); printf("year=%d money=%.0f\n",yea 阅读全文
摘要:
#includeint main(void){ int i,n,numerator,denominator,flag; double sum,item; printf("Enter n:"); scanf("%d",&n); numerator=1; denominator=1; sum=0; flag=1; for(i=1;i<=n;i++){ item=flag*(numerator*1.0/denominator); numerator=numerator+1; denominator... 阅读全文
摘要:
#includeint main(void){ int m,n; double i,y; y=1; printf("输入m,n的值:"); scanf("%d%d",&m,&n); for(i=m;i<=n;i++){ y=y+(i*i+1/i); } printf("y=%Lf",y); return 0;} 阅读全文
摘要:
#includeint main(void){ int n,i; double x,y; y=1; printf("输入n,x:"); scanf("%d%Lf",&n,&x); for(i=1;i<=n;i++){ y=y*x; } printf("y=%Lf",y); return 0;} 阅读全文
摘要:
#includeint main(void){ int num1,num2,a,b,c; double d,e; printf("输入num1,num2:"); scanf("%d%d",&num1,&num2); a=num1+num2; b=num1-num2; c=num1*num2; d=num1/num2; e=num1%num2; printf("输出和=%d差=%d积=%d商=%.2f余数=%.2f",a,b,c,d,e); return 0;}最后的那个余数搞了好久,才发现不能放在int那里面 阅读全文