21天养成良好习惯-15
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a,b;
char ch;
scanf("%d %c %d",&a,&ch,&b);
switch(ch)
{
case ‘+’:printf("%d",a+b);break;
case ‘-’:printf("%d",a-b);break;
case '’:printf("%d",ab);break;
case ‘/’:printf("%d",a/b);break;
case ‘%’:printf("%d",a%b);break;
default:printf(“ERROR”);break;
}
return 0;
}
#include <stdio.h>#include <stdlib.h>#include <math.h>#define EPS 1e-6int main(){ float a,b,c,m,p,q; scanf("%f %f %f",&a,&b,&c); m=bb-4ac; if(fabs(a)<=EPS) { if(b!=0&&c!=0) printf(“x = %g”,-c/b); if(b!=0&&c0) printf(“x = 0”); if(b0&&c!=0) printf(“无解”); if(b0&&c0) printf(“无穷多解”); } p=-b/(2a),q=sqrt(fabs(m))/(2*a); if(fabs(a)>EPS) { if(m>0) printf(“x1 = %g, x2 = %g”,p+q,p-q); if(m0&&b!=0) printf(“x1 = x2 = %g”,p); if(m0&&b0) printf(“x1 = x2 = 0”); if(m<0&&b!=0) printf(“x1 = %g+%.1fi, x2 = %g+%.1fi”,p,q,p,q); if(m<0&&b0) printf(“x1 = 0+%gi, x2 = 0-%gi”,q,q); } return 0;}