Home Article Practice c1

c1

2022-01-02 12:16  views:533  source:小键人3919956    

#include <stdio.h>
int main(void)
{
int a, b, c;
int x=0;
printf("请输入三个数:\n");
scanf("%d %d %d",&a,&b,&c);
if(a>b&&a>c)
x=a;
if(b>a&&b>c)
x=b;
if(c>a&&c>b)
x=c;
printf("max=%d\n",x);
return 0;
}
#include <stdio.h>
int main(void)
{
int i, a[10], s=0;
printf("请输入十个数:\n");
for(i=0;i<=9;i++)
scanf("%d",&a[i]);
for(i=0;i<=9;i++)
if(s<a[i])
s=a[i];
printf("最大的数是:%d\n",s);
return 0;
}
#include <stdio.h>
int main(void)
{
int i,j,a[100],s=0,n;
printf("n:\n");
scanf("%d",&n);
printf(":\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n-1;i++){
for(j=i+1;j<n;j++){
if(a[i]>a[j]){
s=a[i];
a[i]=a[j];
a[j]=s;
}
}
}
for(i=0;i<n;i++)
printf("%d ",a[i]);
printf("\n");
for(i=n-1;i>=0;i--)
printf("%d ",a[i]);
return 0;
}
#include <stdio.h>
#include <math.h>
int main(void)
{
double a, b, c, s, area;
printf("please input:");
scanf("%lf %lf %lf",&a,&b,&c);
if(a+b>c&&a+c>b&&b+c>a){
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("area is %f\n",area);
return 0;
}
else;
}
#include <stdio.h>
int main()
{
int temp,i,j,a,n,sum=0;
scanf("%d %d",&a,&n);
temp=a;
for(i=0;i<n;i++)
{
sum=sum+a;
printf("%d + ",a);
a=a*10+temp;
}
printf("=%d",sum);
return 0;
}
#include <stdio.h>
int main()
{
float e=1.0,n=1.0;
int i=1;
while(1/n>1e-10)
{
e+=1/n;
i++;
n=i*n;
}
printf("e的值为:%f\n",e);
return 0;
}
#include<stdio.h>
int main()
{
int mark;
scanf("%d",&mark);
switch (mark/10)
{
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;
}
}



Disclaimer: The above articles are added by users themselves and are only for typing and communication purposes. They do not represent the views of this website, and this website does not assume any legal responsibility. This statement is hereby made! If there is any infringement of your rights, please contact us promptly to delete it.

字符:    改为:
去打字就可以设置个性皮肤啦!(O ^ ~ ^ O)