实验3
作者:互联网
#include <math.h> #include <stdio.h> #include <stdlib.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)) { if(a == 0) printf("not quadratic equation.\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 = %f, x2 = %f\n", x1, x2); } else { real = -b/(2*a); imag = sqrt(-delta) / (2*a); printf("x1 = %f + %fi, x2 = %f - %fi\n", real, imag, real, imag); } } printf("Enter a, b, c:\n"); } system("pause"); return 0; }
#include <stdio.h> #include <stdlib.h> #include <time.h> int main() { int guessNumber; int ans; // 存放用户猜的数字 srand((time(0))); // 以时间函数作为随机种子 guessNumber = 1 + rand()%100; // 生成1~100之间的随机数 do { printf("your guess number is(1~100): "); scanf("%d", &ans); if(ans < guessNumber) printf("%d is lower than the number.\n", ans); else if(ans > guessNumber) printf("%d higher then the number.\n", ans); }while(ans != guessNumber); printf("Congratulations. you hit it~\n"); system("pause"); // 在devc中运行时,这一行可以去掉 return 0; }
#include <stdio.h> #include <stdlib.h> int main() { int number, max, min, n; n=1; printf("输入第%d个数: ", n); scanf("%d", &number); max = number; min = number; while(/*补足①*/) { n++; printf("输入第%d个数: ", n); scanf("%d", &number); if(/*补足②*/) max = number; else if(/*补足③*/) min = number; } printf("最大数为: %d\n", max); printf("最小数为: %d\n", min); system("pause"); return 0; }
#include<stdio.h> int isprime(int n); int main() { int i,j; j=0; for(i=101;i<=200;i++) { if(isprime(i)) printf("%4d",i); if(i%25==0) printf("\n"); } for(i=101;i<=200;i++) { if(isprime(i)) j=j+1; } printf("\n101~200之间共有%d个素数",j); getchar(); return 0; } int isprime(int n) { int k; for(k=2;k<=n/2;k++) if(n%k==0) return 0; return 1; }
#include<stdio.h> int main(){ long sr; int a,b,c,d,e,f,g,h; printf("请输入一个八位数"); scanf("%ld",&sr); a=int(sr/10000000); if(a%2==1) printf("a"); b=int(sr-10000000*a); if(b%2==1) printf("b"); c=int(sr-10000000*a-1000000*b); if(c%2==1) printf("c"); d=int(sr-10000000*a-1000000*b-100000*c); if(d%2==1) printf("d"); e=int(sr-10000000*a-1000000*b-100000*c-10000*d); if(e%2==1) printf("e"); f=int(sr-10000000*a-1000000*b-100000*c-10000*d-1000*e); if(f%2==1) printf("f"); g=int(sr-10000000*a-1000000*b-100000*c-10000*d-1000*e-100*f); if(g%2==1) printf("g"); h=int(sr-10000000*a-1000000*b-100000*c-10000*d-1000*e-100*f-10*g); if(h%2==1) printf("h"); getchar(); return 0; }
不知道咋做。。。
标签:10000000,int,sr,number,实验,printf,include 来源: https://www.cnblogs.com/zysheep/p/11894048.html