//一元二次方程的
#include#include int main () { double a,b,c,x1,x2; double delat,real,imag; while(scanf("%lf %lf %lf",&a,&b,&c)){ if(a==0) printf("illegal\n"); else{ delat=b*b-4*a*c; if(delat>=0){ x1=-b+sqrt(delat)/(2*a); x2=-b-sqrt(delat)/(2*a); printf("x1=%lf x2=%lf\n",x1,x2); } if(delat<0){ real=-b/(2*a); imag=sqrt(-delat)/(2*a); printf("x1=%lf+%lfi x2=%lf-%lfi\n",real,imag,real,imag); } } printf("ENTER"); } return 0; }
//判断最值
#includeint main (){ int MAX,MIN,n,a; scanf("%d",&n); MAX=n; MIN=n; for(int i=1;i<=4;++i){ scanf("%d",&a); if(a<=n) MIN=a; else MAX=a; } printf("%d %d",MAX,MIN); return 0; }
//奇数倒叙输出的第一种方法
#includeint main (){ int a[8]; for(int i=0;i<=7;++i) scanf("%1d",&a[i]); for(int i=0;i<=7;++i){ if(a[i]%2) printf("%d",a[i]); } return 0; }
//第二种方法
#includeint main (){ long n,m; scanf("%ld",&n); while(n>1){ m=n%10; n/=10; if(m%2) printf("%ld",m); } return 0; }
//输出1/a+1/aa+... 的那个
#includeint main (){ int n,a; scanf("%d %d",&n,&a); double sum=1.0/a; int fm=a;//分母,(英文不造啊,尴尬 double each=0; for(int i=2;i<=n;++i){ fm=fm*10+a; each=i/(double)fm; sum+=each; } printf("%lf",sum); return 0; }
#include#include int Isprime(int n); int main(){ int i,m=0; for(i=101;i<=200;i++) { if(Isprime(i)) { printf("%6d",i); m+=1; if(m%5==0) printf("\n"); } } printf("\n"); printf("有%d个素数",m); return 0; } int Isprime(int n) { int k; for(k=2;k<=sqrt(n);k++) if(n%k==0) return 0; return 1; }
PS:那个猜数的程序我还没太搞懂,应该再下一次博客里写出来