5.5
#include<stdio.h>
void main()
{
float x,y;
scanf("%f",&x);
if(x<10)
{ if(x<1)
y=x;
else
y=2*x-1;
}
else
y=3*x-11;
printf("%f\n",y);
}
5.6
#include<stdio.h>
void main()
{int x,y;
scanf("%d",&x);
y=x/10;
switch(y)
{
case 10,
case 9:printf("A\n");break;
case 8:printf("B\n");break;
case 7:printf("C\n");break;
case 6:printf("D\n");break;
default:printf ("E\n");break;
}
}
1.6
#include<stdio.h>
void main()
{float a,b,c,x,y;
scanf("%f,%f,%f",&a,&b,&c);
if(a>b) x=a;
else x=b;
if(x>c) y=x;
else y=c;
printf("%5.2f\n",y);
}
4.9
#include<stdio.h>
void main()
{float F,c;
scanf("%f",&F) ;
c=5*(F-32)/9;
printf("%5.2f\n",c);
}
2.4(5)
#include <stdio.h>
void main()
{int n,t,i;
scanf("%d",&n);
t=n%3;
if(t=0)
{i=n%5;
if(i=0)
printf("%d can",n);
else
printf("%d can't",n);
}
else
printf("%d can't",n);
}
5.9 解法一
#include<stdio.h>
void main()
{
int a,b,c,d,t;
scanf("%d,%d,%d,%d",&a,&b,&c,&d);
if(a>b)
{t=a;a=b;b=t;}
if(a>c)
{t=a;a=c;c=t;}
if(a>d)
{t=a;a=d;d=t;}
if(b>c)
{t=b;b=c;c=t;}
if(b>d)
{t=b;b=d;d=t;}
if(c>d)
{t=c;c=d;d=t;}
printf("%d,%d,%d,%d\n",a,b,c,d);
}
解法二
#include<stdio.h>
void main()
{
int a[4];
int i,j,t;
printf("input 4 numbers:\n");
for(i=0;i<4;i++)
scanf("%d,",&a[i]);
printf("\n");
for(j=0;j<3;j++)
for(i=0;i<3-j;i++)
if(a[i]>a[i+1])
{
t=a[i];
a[i]=a[i+1];
a[i+1]=t;
}
printf("the sorted numbers:\n");
for(i=0;i<4;i++)
printf("%d,",a[i]);
printf("\n");
}
#include<stdio.h>
void main()
{
float x,y;
scanf("%f",&x);
if(x<10)
{ if(x<1)
y=x;
else
y=2*x-1;
}
else
y=3*x-11;
printf("%f\n",y);
}
5.6
#include<stdio.h>
void main()
{int x,y;
scanf("%d",&x);
y=x/10;
switch(y)
{
case 10,
case 9:printf("A\n");break;
case 8:printf("B\n");break;
case 7:printf("C\n");break;
case 6:printf("D\n");break;
default:printf ("E\n");break;
}
}
1.6
#include<stdio.h>
void main()
{float a,b,c,x,y;
scanf("%f,%f,%f",&a,&b,&c);
if(a>b) x=a;
else x=b;
if(x>c) y=x;
else y=c;
printf("%5.2f\n",y);
}
4.9
#include<stdio.h>
void main()
{float F,c;
scanf("%f",&F) ;
c=5*(F-32)/9;
printf("%5.2f\n",c);
}
2.4(5)
#include <stdio.h>
void main()
{int n,t,i;
scanf("%d",&n);
t=n%3;
if(t=0)
{i=n%5;
if(i=0)
printf("%d can",n);
else
printf("%d can't",n);
}
else
printf("%d can't",n);
}
5.9 解法一
#include<stdio.h>
void main()
{
int a,b,c,d,t;
scanf("%d,%d,%d,%d",&a,&b,&c,&d);
if(a>b)
{t=a;a=b;b=t;}
if(a>c)
{t=a;a=c;c=t;}
if(a>d)
{t=a;a=d;d=t;}
if(b>c)
{t=b;b=c;c=t;}
if(b>d)
{t=b;b=d;d=t;}
if(c>d)
{t=c;c=d;d=t;}
printf("%d,%d,%d,%d\n",a,b,c,d);
}
解法二
#include<stdio.h>
void main()
{
int a[4];
int i,j,t;
printf("input 4 numbers:\n");
for(i=0;i<4;i++)
scanf("%d,",&a[i]);
printf("\n");
for(j=0;j<3;j++)
for(i=0;i<3-j;i++)
if(a[i]>a[i+1])
{
t=a[i];
a[i]=a[i+1];
a[i+1]=t;
}
printf("the sorted numbers:\n");
for(i=0;i<4;i++)
printf("%d,",a[i]);
printf("\n");
}