小宝的实验7-综合练习

#include <stdio.h>
void main( )
{
     int i, j, t, a[10];
     printf("Enter 10 integers: ");
     for(i = 0; i < 10; i++)
         scanf("%d", &a[i]);/*输入为整形*/
     for(i = 1; i < 10; i++)
         for(j = 0;j < 10 - i; j++)
             if(a[j] < a[j+1])
             {
                 t = a[j];
                 a[j] = a[j+1];
                 a[j+1] = t;
             }
     printf("After sorted: ");
     for(i = 0; i < 10; i++)
         printf("%d ", a[i]);
     printf("
");
}
/*输入一批学生的成绩,遇0或负数则输入结束,要求统计并输出优秀(大于85)、通过(60~84)和不及格(小于60)的学生人数。*/
#include<stdio.h>
int main()
{
    int a,b,c,mark;
    a=0;
    b=0;
    c=0;/*a是优秀,b是通过的,c是不及格的*/
    printf("Enter mark:");
    scanf("%d",&mark);
    while(mark>0){
        if(mark>=85){
            a++;
        }
        else if((mark>=60)&&(mark<=84)){
            b++;
        }
        else{
            c++;
        }
        scanf("%d",&mark);
    }
    printf(">=85:%d",a);
    printf("60-84:%d",b);
    printf("<60:%d",c);
    return 0;
}
#include<stdio.h>
#include<math.h>
int main()
{
    double x,y;

    printf("Enter x:");
    scanf("%lf",&x);
    if(x<-2){
        y=x*x;
    }
    else if(x>2){
        y=sqrt(x*x+x+1);
    }
    else{
        y=2+x;
    }
    printf("f(%.2f)=%.2f
",x,y);

    return 0;
}
#include <stdio.h>
void main( )
{
     int i, b = 1;
     double s;
     s=0; /* s由0开始,对s进行赋初值*/
     for(i = 1; i <= 15; i++)
     {
         s = s +double(i)/double(b); /*i和b为变量*/
         b = b + 2; /*由题目可知 分母是公差为2的等差数列*/
     }
     printf("sum = %f
", s);/*由运行结果可知 输出结果为浮点形*/
 }
原文地址:https://www.cnblogs.com/choubao/p/3398528.html