1
程序错误很多啊,
1.#includ
2.包含头文件 #include
3.vodi main() 改为void main() //拼写错误
4.ch[3][15]={"morning","afternoon","night","evening"};
改为ch[4][15]={"morning","afternoon","night","evening"}; //4个字符数组,3个保存不下
5.printf("%s\n",name[k];) 改为printf("%s\n",name[k]);//分号位置错误
答案是:
afternoon
evening
morning
night
-----------------------------
2
C
-----------------------------
3
函数指针
源程序应该是这样的吧?
#include
#include
void func(char *a[],int n)
{
int i,j,l;char *temp;
for(i=0;i
l=i;
for(j=i+1;j
if(strcmp(a[j],a[l])<0) l=j;
if(l!=i)
{
temp=a[i];
a[i]=a[l];
a[l]=temp;
}
}
}
}
void main ()
{
char *name[4],ch[4][15]={"morning","afternoon","night","evening"};
int k;
for(k=0;k<4;k++)
name[k]=ch[k];
func(name,4);
for(k=0;k<4;k++)
printf("%s\n",name[k]);
}
答案是:
afternoon
evening
morning
night
Press any key to continue
函数指针吧