标签:amp adr loading else ima ati png http bsp
#include<math.h> #include<stdio.h> int main(){ float a,b,c,x1,x2; float delta,real,imag; printf("Enter a,b,c:"); while(scanf("%f%f%f",&a,&b,&c) != EOF){ if(a == 0) printf("not quadratic equation.\n\n"); else{ delta = b*b-4*a*c; if(delta>=0){ x1 = (-b+sqrt(delta))/(2*a); x2 = (-b-sqrt(delta))/(2*a); printf("x1 = %.2f,x2 = %.2f\n\n",x1,x2); } else{ real = -b/(2*a); imag = sqrt(-delta)/(2*a); printf("x1 = %.2f+%.2fi,x2 = %.2f-%.2fi\n\n",real,imag,real,imag); } } printf("Enter a,b,c:"); } return 0; }
#include<stdio.h> #include<stdlib.h> #include<time.h> #define N 5 int main(){ int x,n; srand(time(0)); n=0; do{ n++; x=rand()%10; printf("%3d",x); }while(n<N); printf("\n"); return 0; }
#include<stdio.h> #include<math.h> int main(){ int n,i,m; double k; m=0; for(n=101;n<=200;n++){ k=sqrt(n); for(i=2;i<=k;i++){ if(n%i==0) break; } if(i>k){ printf("%5d",n); m++; } } printf("\n"); printf("101~200之间共有%d个素数\n",m); return 0; }
#include<stdio.h> int main(){ long s; int m,sum,i; i=1; printf("Enter a number:"); while(scanf("%ld",&s)!=EOF){ while(s>0){ m=s%10; if(m%2!=0){ sum+=m*i; i*=10; } s=s/10; } printf("new number is:%d\n",sum); printf("Enter a number:"); } return 0; }
#include<stdio.h> #include<math.h> int main(){ int n,i,m; float s; printf("Enter n(1~10):"); while(scanf("%d",&n)!=EOF){ s=0.0; m=1; for(i=1;i<=n;i++){ m*=i; s+=pow(-1,i-1)/m; } printf("n = %d,s = %f\n",n,s); printf("Enter n(1~10):"); } return 0; }
#include<stdio.h> #include<stdlib.h> #include<time.h> int main(){ int n,x,m; printf("猜猜2020年12月哪一天会是你的luck day\n"); srand(time(0)); m=(rand()%(31-1+1))+1; x=1; printf("%d\n",m); printf("开始喽。你有三次机会,猜吧(1~31):"); do{ scanf("%d",&n); if(n==m) break; else if(n<m){ printf("你猜的日期早了,luck day还没到呢\n"); x++; } else{ printf("你猜的日期晚了,luck day悄悄溜到前面啦\n"); x++; } if(x<3) printf("再猜(1~31):"); }while(x<=3); if(x>3){ printf("次数用完啦。偷偷告诉你:12月,你的luck day是%d号",m); } return 0; }
标签:amp adr loading else ima ati png http bsp
原文地址:https://www.cnblogs.com/yyd2002/p/13976396.html