标签:class eal 个数 com define adr include enter ret
#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> int main() { int n,m,count; count==0; for(n=100;n<200;n++) { for(m=2;m<=n;m++) { if(n%m==0) { break; } } if(n==m) { count++; printf("%d ",n); if(count%5==0) printf("\n"); } } printf("\n这一区间内素数个数:%d\n",count); return 0 ; }
#include<stdio.h> #include<math.h> int main() { int m,n; printf("Enter a number:"); while(scanf("%d",&n)!=EOF) { int i=0,s=0; do { m=n%10; if(n%2!=0) { s=s+m*pow(10,i); i++; } n=n/10; }while(n!=0); printf("new number is:%d",s); printf("\n"); printf("Enter a number:"); } return 0; }
#include<stdio.h> #include<math.h> #include<stdlib.h> int main(){ float s,sum; int n; printf("Enter n(1~10):"); while(scanf("%d",&n)!=EOF){ sum=0.0,s=1.0; int i; for(i=1;i<=n;++i){ s=s*i; sum=sum+pow(-1,i-1.0)/s; } printf("n=%d,sum=%lf\n",n,sum); printf("Enter n(1~10):\n");} return 0; }
#include<stdio.h> #include<time.h> #include<stdlib.h> int main() { int x,n,i=0; srand(time(0)); x=1+rand()%31; printf("猜猜2020年12月哪一天会是你的luck day\n开始喽,你有三次机会,猜吧(1~31):"); while(1) { scanf("%d",&n); if(n==x) { printf("恭喜你猜对了"); break; } else { if(n>x) printf("你猜的日期晚了,luck day悄悄溜到前面啦"); else printf("你猜的日期早了,luck day还没到呢"); i=i+1; if(i>2) { printf("\n次数用完了。偷偷告诉你:12月,你的luck day是%d号",x); break; } printf("\n"); printf("再猜(1~31):"); } } return 0; }
标签:class eal 个数 com define adr include enter ret
原文地址:https://www.cnblogs.com/xjs2002/p/13986537.html