Nefu 锐格c实验5

记录一下现在写的代码,以后深造或者工作了还能翻出来拷打一下之前的自己。

5885 结构体的读入和输出

#include
#include
struct student
{
    long int sno;
    char name[20];
    float score;
};
int main()
{
    int n;
    scanf("%d",&n);
    struct student stu[n];
    int i;
    for(i=0;i

5886 结构体输入及成员大小排序

#include
#include
struct student
{
    long int sno;
    char name[20];
    float score;
};
int main()
{
    int n;
    int a1,a2,a3;
    a1=a2=a3=0;
    int i,j;
    scanf("%d",&n);
    struct student stu[n];
    for(i=0;i=60&&stu[i].score<80)
        {
            a2++;
        }
        else
        {
            a1++;
        }
    }
    printf("%d ",a1);
    printf("%d ",a2);
    printf("%d ",a3);
    return 0;
}

5887 结构体成员是数组的求和、求均值操作

#include
#include
struct stu
{
    int xuehao;
    char name[20];
    double score[4];
    double sum;
    double ave;
};
int main()
{
    int n;
    int i,j;
    while(scanf("%d",&n)!=EOF)
    {
        struct stu s[n];
        for(i=0;i

5888 和上一题类似,去掉ave及输出改一下就行

#include
#include
struct stu
{
    int xuehao;
    char name[20];
    double score[4];
    double sum;
};
int main()
{
    int n;
    int i,j;
    while(scanf("%d",&n)!=EOF)
    {
        struct stu s[n];
        for(i=0;is[j+1].sum)
                {
                    tmp=s[j];
                    s[j]=s[j+1];
                    s[j+1]=tmp;
                }
            }
        }
        printf("%d ",s[i].xuehao);
        printf("%s ",s[i].name);
    }
    return 0;
}

5889 同5887(大表哥竟是我自己(bushi )

#include
#include
struct stu
{
    char name[20];
    char xb[2];
    double sg[3];
    double score;
};
int main()
{
    int n;
    int i,j;
    while(scanf("%d",&n)!=EOF)
    {
        struct stu s[n];
        for(i=0;i

你可能感兴趣的:(锐格c下学期,c语言)