# 算法笔记习题2.3

r1=第一个根

r2=第二个根

No real roots!

## 样例输入

1 2 3

## 样例输出

No real roots!

#include <stdio.h>
#include <math.h>
int main()
{
double a,b,c,r1,r2;
scanf("%lf%lf%lf",&a,&b,&c);
if(a==0) return;
else if(b*b-4*a*c<0) printf("No real roots!\n");
else {
printf("r1=%7.2f\n",(-b+sqrt(b*b-4*a*c))/(2*a));
printf("r2=%7.2f\n",(-b-sqrt(b*b-4*a*c))/(2*a));
}
return 0;
} 

## 样例输入

3.6 -2.3

## 样例输出

-2.30 3.60
#include <stdio.h>
int main()
{
double a,b;
scanf("%lf %lf",&a,&b);
if(a>b)  printf("%.2f %.2f\n",b,a);
else printf("%.2f %.2f\n",a,b);
return 0;
}

## 样例输入

3 7 1

## 样例输出

1.00 3.00 7.00

#include <stdio.h>
int main()
{
double a,b,c,temp;
scanf("%lf%lf%lf",&a,&b,&c);
if(a>b&&a>c)
{
if(b>c)
{
printf("%.2f %.2f %.2f\n",c,b,a);
}
else  printf("%.2f %.2f %.2f\n",b,c,a);
}
if(b>a&&b>c)
{
if(a>c)
{
printf("%.2f %.2f %.2f\n",c,a,b);
}
else printf("%.2f %.2f %.2f\n",a,c,b);
}
if(c>a&&c>b)
{
if(a>b)
{
printf("%.2f %.2f %.2f\n",b,a,c);
}
else printf("%.2f %.2f %.2f\n",a,b,c);
}
return 0;
} 

## 样例输入

1 3 2

## 样例输出

3

#include <stdio.h>
int main()
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(a>b&&a>c)  printf("%d",a);
if(b>a&&b>c)  printf("%d",b);
if(c>a&&c>b)  printf("%d",c);
return 0;
}

## 样例输入

1050

## 样例输出

105.00
#include <stdio.h>
#define N1 100000
#define N2 200000
#define N3 400000
#define N4 600000
#define N5 1000000
int main()
{
double prize , profit;
scanf("%lf",&profit);
if(profit<=N1)
{
prize = profit * 0.1;
}
else if (profit<=N2&&profit>N1)
{
prize = N1*0.1+(profit-N1)*0.075;
}
else if (profit<=N3&&profit>N2)
{
prize = N1*0.1 + (N2-N1)*0.075 + (profit-N2)*0.05;
}
else if(profit<=N4&&profit>N3)
{
prize=N1*0.1+(N2-N1)*0.075+(N3-N2)*0.05 + (profit-N3)*0.03;
}
else if(profit<=N5&&profit>N4)
{
prize=N1*0.1+(N2-N1)*0.075+(N3-N2)*0.05 + (N4-N3)*0.03+(profit-N4)*0.015;
}
else prize=N1*0.1+(N2-N1)*0.075+(N3-N2)*0.05 + (N4-N3)*0.03+(N5-N4)*0.015+(profit-N5)*0.01;
printf("%.2f\n",prize);
return 0;
}