2018年江苏大学885编程题
第一题代码:
#include <stdio.h> #include <math.h> #define N 10 int main(){ int i,j,k; double t=0.0,a,b,c; FILE *fp=fopen("data.txt","w+"); for(i=0;i<N;i++){ scanf("%lf%lf%lf",&a,&b,&c); t=(4.25*(a+b)+log(a+b+sqrt(a+b)+1.0/(a+b)))/(4.25*c+log(c+sqrt(c)+1.0/c)); printf("a=%lf b=%lf c=%lf时 T=%lf\n",a,b,c,t); fprintf(fp,"%lf %lf %lf %lf\n",a,b,c,t); } fclose(fp); return 0; }
第二题代码:
#include <stdio.h> #include <math.h> # define N 20 int main(){ int num,i,t,k=0,a[N]; printf("please input a number:\n"); scanf("%d",&num);t=num; while(num!=0){ a[k++]=num%10; num/=10; } for(i=k-1;i>0;i--){ if(a[i]<a[i-1]) break; } if(i==0) printf("%d是降序数\n",t); else printf("%d不是降序数\n",t); return 0; }
第三题代码:
#include <stdio.h> #include <math.h> #define eps 1e-6 int main(){ double x0,x1=-1,f,f1; do{ x0=x1; f=pow(x0,41)+pow(x0,3)+1; f1=41*pow(x0,40)+3*pow(x0,2); x1=x0-f/f1; }while(fabs(x1-x0)>eps); printf("近似根为%lf\n",x1); return 0; }
一纸高中万里风,寒窗读破华堂空。
莫道长安花看尽,由来枝叶几相同?