急求一C语言编程题答案!!!!!
题目内容:1.定义一个数组a【11】,用以存放学生成绩2。从键盘输入10个学生成绩3采用冒泡法将学生成绩按从高到低排序并显示排序后结果4再输入一个学生成绩,将此成绩按排序...
题目内容:1.定义一个数组a【11】,用以存放学生成绩
2。从键盘输入10个学生成绩
3采用冒泡法将学生成绩按从高到低排序并显示排序后结果
4再输入一个学生成绩,将此成绩按排序规律插入原学生成绩数组,显示插入后结果
5将排好序的成绩单进行反序存放,即原来是从高到低,现改为从低到高排序,显示结果!
我用的是VC!!!! 展开
2。从键盘输入10个学生成绩
3采用冒泡法将学生成绩按从高到低排序并显示排序后结果
4再输入一个学生成绩,将此成绩按排序规律插入原学生成绩数组,显示插入后结果
5将排好序的成绩单进行反序存放,即原来是从高到低,现改为从低到高排序,显示结果!
我用的是VC!!!! 展开
展开全部
# include <stdio.h> /*程序从函数main开始执行*/
int main()
{
int interger1,interger2,interger3,Sum,Average,product;
printf( "Input three different intergers\n" );
scanf( "%d%d%d",&interger1,&interger2,&interger3 );
Sum = interger1 + interger2 + interger3;
printf( "Sum is %d\n",Sum );
Average = ( interger1 + interger2 + interger3 ) / 3;
printf( "Average is %d\n",Average );
Product = interger1 * interger2 * interger3;
printf( "Product is %d\n",Product );
if ( interger1 > interger2 && interger2 > interger3 )
{
printf( "Smallest is %d\n",interger3 );
printf( "Largest is %d\n",interger1 );
}
if ( interger2 > interger3 && interger3 > interger1 )
{
printf( "Smallest is %d\n",interger1 );
printf( "Largest is %d\n",interger2 );
}
if ( interger3 > interger2 && interger2 > interger1 )
{
printf( "Smallest is %d\n",interger1 );
printf( "Largest is %d\n",interger3 );
}
if ( interger1 > interger3 && interger3 > interger2 )
{
printf( "Smallest is %d\n",interger2 );
printf( "Largest is %d\n",interger1 );
}
if ( interger2 > interger1 && interger1 > interger3 )
{
printf( "Smallest is %d\n",interger3);
printf( "Largest is %d\n",interger2 );
}
if ( interger3 > interger1 && interger1 > interger2 )
{ printf( "Smallest is %d\n",interger2 );
printf( "Largest is %d\n",interger3 );
}
return 0;
}
int main()
{
int interger1,interger2,interger3,Sum,Average,product;
printf( "Input three different intergers\n" );
scanf( "%d%d%d",&interger1,&interger2,&interger3 );
Sum = interger1 + interger2 + interger3;
printf( "Sum is %d\n",Sum );
Average = ( interger1 + interger2 + interger3 ) / 3;
printf( "Average is %d\n",Average );
Product = interger1 * interger2 * interger3;
printf( "Product is %d\n",Product );
if ( interger1 > interger2 && interger2 > interger3 )
{
printf( "Smallest is %d\n",interger3 );
printf( "Largest is %d\n",interger1 );
}
if ( interger2 > interger3 && interger3 > interger1 )
{
printf( "Smallest is %d\n",interger1 );
printf( "Largest is %d\n",interger2 );
}
if ( interger3 > interger2 && interger2 > interger1 )
{
printf( "Smallest is %d\n",interger1 );
printf( "Largest is %d\n",interger3 );
}
if ( interger1 > interger3 && interger3 > interger2 )
{
printf( "Smallest is %d\n",interger2 );
printf( "Largest is %d\n",interger1 );
}
if ( interger2 > interger1 && interger1 > interger3 )
{
printf( "Smallest is %d\n",interger3);
printf( "Largest is %d\n",interger2 );
}
if ( interger3 > interger1 && interger1 > interger2 )
{ printf( "Smallest is %d\n",interger2 );
printf( "Largest is %d\n",interger3 );
}
return 0;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
/*程序已测试过,复制粘贴应该就可以跑;4的问题可能要用直接插入排序,这里偷懒,依然用冒泡排了*/
#include <stdio.h>
int sort(int *a, int num) //冒泡
{
int i = 0;
int j = 0;
int tmp = 0;
for(i = 0; i < num; i++)
{
for(j = 1; j < num; j++)
{
if(a[j-1] < a[j])
{
tmp = a[j-1];
a[j-1] = a[j];
a[j] = tmp;
}
}
}
return 0;
}
int reverse(int *a, int num) //反转
{
int i = 0;
int tmp = 0;
for(i = 0; i < num/2; i++)
{
tmp = a[i];
a[i] = a[num-1-i];
a[num-1-i] = tmp;
}
return 0;
}
int main(int argc, char* argv[])
{
int a[11] = {0};
int i = 0;
//input
for(i = 0; i < 10; i++)
{
scanf("%d",&a[i]);
}
//sort
sort(a,10);
//output
for(i = 0; i < 10; i++)
{
printf("[%d]",a[i]);
}
printf("\n");
//insert
scanf("%d",&a[10]);
printf("\n");
//sort
sort(a,11);
//output
for(i = 0; i < 11; i++)
{
printf("[%d]",a[i]);
}
//reverse
reverse(a,11);
printf("\n");
//output
for(i = 0; i < 11; i++)
{
printf("[%d]",a[i]);
}
printf("\n");
return 0;
}
}
#include <stdio.h>
int sort(int *a, int num) //冒泡
{
int i = 0;
int j = 0;
int tmp = 0;
for(i = 0; i < num; i++)
{
for(j = 1; j < num; j++)
{
if(a[j-1] < a[j])
{
tmp = a[j-1];
a[j-1] = a[j];
a[j] = tmp;
}
}
}
return 0;
}
int reverse(int *a, int num) //反转
{
int i = 0;
int tmp = 0;
for(i = 0; i < num/2; i++)
{
tmp = a[i];
a[i] = a[num-1-i];
a[num-1-i] = tmp;
}
return 0;
}
int main(int argc, char* argv[])
{
int a[11] = {0};
int i = 0;
//input
for(i = 0; i < 10; i++)
{
scanf("%d",&a[i]);
}
//sort
sort(a,10);
//output
for(i = 0; i < 10; i++)
{
printf("[%d]",a[i]);
}
printf("\n");
//insert
scanf("%d",&a[10]);
printf("\n");
//sort
sort(a,11);
//output
for(i = 0; i < 11; i++)
{
printf("[%d]",a[i]);
}
//reverse
reverse(a,11);
printf("\n");
//output
for(i = 0; i < 11; i++)
{
printf("[%d]",a[i]);
}
printf("\n");
return 0;
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
加分我给你程序
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询