今日错误(C语言)(定义二维数组储存)
#include <stdio.h>
#include <string.h>
#define P 1000
int main()
{
int i, j,K,N;
char s[P][P], temp[P];
printf("请输入N和K的值:");
scanf("%d %d", &N, &K);
for (i = 1; i <= N; i++)
{
scanf("%s", &s[i]);
}
for (i = 1; i <= K; i++)
{
for (j = 1; j <= N - 1; j++)
{
if (strcmp(s[j], s[j + 1]) > 0)
{
strcpy(temp, s[j]);
strcpy(s[j], s[j + 1]);
strcpy(s[j + 1], temp);
}
}
}
printf("交换后:\n");
for (i = 1; i <= N; i++)
{
printf("%s\n", s[i]);
}
}