标签:float scanf class col amp include image while loading
# include<stdio.h> # include<stdlib.h> # include<math.h> int main(){ float a,b,c,x1,x2; float delta,real,imag; printf("请输入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("entera,b,c:"); } return 0 ; }
# include<stdio.h> # include<stdlib.h> # include<time.h> # define N 10 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 i,m,n,count; count=0; for(m=101;m<=200;m++){ n=sqrt(m); for(i=2;i<=n;i++){ if(m%i==0)break; } if(i>n){ printf("%6d",m); count++; if (count%5==0) printf("\n"); } } printf("\n101~200间有%d个素数.",count); return 0; }
标签:float scanf class col amp include image while loading
原文地址:https://www.cnblogs.com/clostdue/p/13966034.html