建议在镇橡尺第二个getchar()前加上一句:
fflush(stdin)
有二个地方必须要改一下:
第一,read改为myread(共有3处)
第二,switch(a)要改为switch(p)
#include <stdio.h>
void myread(int)
int main()
{
char i
printf("please input a number:")
scanf("%d",&枯销粗i)
myread(i)
printf("\n")
return 0
}
void myread(int p)
{
switch(p){
case 0: printf("ling ")break
case 1: printf("yi ")break
case 2: printf("斗芹er "没镇)break
case 3: printf("san ")break
case 4: printf("si ")break
case 5: printf("wu ")break
case 6: printf("liu ")break
case 7: printf("qi ")break
case 8: printf("ba ")break
case 9: printf("jiu ")break
}
}
void selection_sort(int array[],int n){
int i
int max
if (n == 1)//<------------------
{
return
}
else if(n == 2)//<察敬------------------
{
if (array[0] > array[1])
{
max = array[0]
array[0] = array[1]
array[1] = max
}
return
}
else
{
if (array[0] > array[1])
{
max = array[0]
}
else
{
max = array[1]
}
for(i = 2 i < 改伍n i++)
{
if (array[i] > max)
{
max = array[i]
}
}
for (i = 0 i < n i++)
{
if (max == array[i])
{
array[i] = 核没或array[n]
array[n] = max
n--
goto done
}
}
}
done:
selection_sort(array,n - 1)
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)