标签:ima eal time src adr inf img style real
#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%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> int main(){ int n,i,k=0; for(n=101;n<=200;n++){ int j=0; for(i=2;i<=n;i++) if(n%i==0) { j++; } if(j==1) { printf("%d\n",n); k++; } } printf("101~200之间一共有%d个素数",k); return 0; }
#include<stdio.h> int main(){ long int s,t,m=0,n=1; scanf("%ld",&s); printf("Enter a number is:%ld\n",s); while(s){ t=s%10; if(t%2!=0) { m=m+t*n; n=n*10; } s=s/10; } printf("new number is:%ld\n",m); return 0; }
#include<stdio.h> #include<stdlib.h> int main(){ double sum=0,p=1; int n,i; scanf("%d",&n); for(i=1;i<=n;i++) { p=p/i; if(i%2==0) {sum=sum-p; } else{sum=sum+p; } } printf("n=%d,sum=%lf",n,sum); return 0; }
#include<stdio.h> #include<stdlib.h> #include<time.h> int main(){ int m,n,t; srand((int)time(0)) ; t=rand()%30; n=1; printf("2020which day is lucky day?\n"); scanf("%d",&m); while(n<=2){ if(m<t){ printf("It is too early\ntry again"); scanf("%d",&m); n++; } else if(m>t){ printf("It is too late\ntry again"); scanf("%d",&m); n++;} else if(m=t){ printf("Got it!"); n++; } } printf("To tell you,in December,your lucky day is:%d",t); return 0;}
标签:ima eal time src adr inf img style real
原文地址:https://www.cnblogs.com/YUyu0804/p/13976537.html