Skip to content

Homework for luo‘si by software1715 qidianxuan #1

@InnocentYoume

Description

@InnocentYoume

#include<stdio.h>
#define N 999
void Add();
int main()
{
int Grade[N];

int iC,n,n1=0;
printf("Please input the number of the students you want:___\b\b\b");
scanf("%d",&n); //From now on, "n" is what you inputed!

for(iC=0;iC<n;iC++)
{
	n1++;
	printf("Input your No.%d student's Grade:__\b\b",n1);
	scanf("%d",&Grade[iC]);
    if(Grade[iC]<0)
    {
        printf("The Grade you inputed is illegal\n");
        return 0;
    }
}

printf("The array you inputed is:");
for(iC=0;iC<n;iC++)
{
	printf("%d ",Grade[iC]);
}    //Output the array you inputed!

//Bubble sort
int i,temp;
for(iC=0;iC<n-1;iC++)
	for(i=0;i<n-1-iC;i++)
	{
		if(Grade[i]<Grade[i+1])
		{
		    temp=Grade[i];
		    Grade[i]=Grade[i+1];
		    Grade[i+1]=temp;
		}
	}

//Output the array after babble sort!
printf("\nThe array reorganized is:");
for(iC=0;iC<n;iC++)
{
	printf("%d ",Grade[iC]);
}
printf("\n");


//Output max and min
printf("The highest socre is :%d\nThe Lowest socre is :%d\n",Grade[0],Grade[n-1]);

Add();

return 0;

}
void Add()
{

char Names[N];
printf("Input whatever you want:"
        "\n_____________________________\r");
scanf("%s",&Names);
printf("%s",Names);

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions