📄 pntrsrt.txt
字号:
谁能告诉我这个程序什么地方错了!
#include "stdio.h"
main()
{
int j=0,k=0,temp,n,m=0,*pm,*pn;
printf("nHow many datas do you want to input ?:n");
scanf("%d",&n);
printf("You input %d data.n",n );
pm=(int *)malloc(n*sizeof(int));
pn=(int *)malloc(n*sizeof(int));
while(k<n)
{
printf("nPlease input %dth number:n",k+1);
scanf("%d",pm + k);
k++;
}
for(k=0;k<n;k++)/*将PM指向的中前N个整数按由小到大的顺序排序,存入PN指向的数组中*/
{
m=0;
for(j+1;j<n;j++)
{
if (pm[j]<pm[m])
m=j;
}
pn[k]=pm[m];/*将PM指向的数组中的最小数存入PN指向的数组中*/
pm[m]=32767;/*将PM中的已选择的最小数用32767填入*/
}
printf("The sorted array is :n");
for(k=0;k<n;k++)
printf("%d",pn[k]);
}
#include <stdio.h>
#include <malloc.h>//define it
void main()
{
int j=0,k=0,temp,n,m=0,*pm,*pn;
printf("How many datas do you want to input ?:\n");
scanf("%d",&n);
printf("You input %d data\n",n); //enter is \n
pm=(int *)malloc(n*sizeof(int));
pn=(int *)malloc(n*sizeof(int));
while(k<n)
{
printf("Please input %dth number:",k+1);
scanf("%d",pm+k);
k++;
}
for(k=0;k<n;k++)/*将PM指向的中前N个整数按由小到大的顺序排序,存入PN指向的数组中*/
{
m=0;
for(j=1;j<n;j++) //it's not j+1---------------------error!
{
if (pm[j]<pm[m])
m=j;
}
pn[k]=pm[m];/*将PM指向的数组中的最小数存入PN指向的数组中*/
pm[m]=32767;/*将PM中的已选择的最小数用32767填入*/
}
printf("The sorted array is :\n");
for(k=0;k<n;k++)
printf("%d ",pn[k]);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -