关于C++的题目,求详细解答,谢谢!!
Writingafunctiontosortanintegerarrayfromlowesttohighestbyapplyingeitherselectionsorto...
Writing a function to sort an integer array from lowest to highest by applying either selection sort or bubble sort. The main function and sort function prototype is already given to you. To write the function below the main function.
void SortIntegerArray(int a [], int n);
#include <stdio.h>
#define N 10
main()
{
int i,array[N];
printf(“Input the number to be sorted:”);
for(i=0;i<N;i++)
scanf(“%d”,&array[i]);
SortIntegerArray(array,N);
for(i=0;i<N;i++)
printf(“%d”,array[i]);
} 展开
void SortIntegerArray(int a [], int n);
#include <stdio.h>
#define N 10
main()
{
int i,array[N];
printf(“Input the number to be sorted:”);
for(i=0;i<N;i++)
scanf(“%d”,&array[i]);
SortIntegerArray(array,N);
for(i=0;i<N;i++)
printf(“%d”,array[i]);
} 展开
1个回答
展开全部
void SortIntegerArray(int a[], int n){
int i,j,temp;n--;
for(i=0;i<n;i++)
for(j=0;j<n-i;j++)
if(a[j]>a[j+1]){temp=a[j];a[j]=a[j+1];a[j+1]=temp;}
};
#include <stdio.h>
#define N 10
void main()
{
int i,array[N];
printf(\"Input the number to be sorted:\");
for(i=0;i<N;i++)
scanf(\"%d\",&array[i]);
SortIntegerArray(array,N);
for(i=0;i<N;i++)
printf(\"%d \",array[i]);
int i,j,temp;n--;
for(i=0;i<n;i++)
for(j=0;j<n-i;j++)
if(a[j]>a[j+1]){temp=a[j];a[j]=a[j+1];a[j+1]=temp;}
};
#include <stdio.h>
#define N 10
void main()
{
int i,array[N];
printf(\"Input the number to be sorted:\");
for(i=0;i<N;i++)
scanf(\"%d\",&array[i]);
SortIntegerArray(array,N);
for(i=0;i<N;i++)
printf(\"%d \",array[i]);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询