m0_74590366 2022-12-13 20:50 采纳率: 87.5%
浏览 12
已结题

为什么会读取访问权限冲突??哪里有错??

#include <stdio.h>
#include<string.h>
int main()
{
char name[10][10] = { "America","China","France","Germany","Australia","Japan","Korea","Russia","England","India" };/initialize the name array/
int i, j;/counters of row and column/
char* a[10];/define the point array of the fisrt character of names/
char* x[1];

printf("Input the English names of ten countries:\n");


for (i = 0; i < 10; i++) {

    a[i] = &name[i][0];/*assign the address of the first character of name to the point array*/

}

/*bubble sorting*/
for (i = 0; i < 10; i++) {

    for (j = 0; j < 10; j++) {

        if (a[j], a[j + 1] > 0) {
            x[0] = a[j];
            a[j] = a[j + 1];
            a[j + 1] = x[0];

        }
    }


    printf("The sorted order of names is:\n");

    for (i = 0; i < 10; i++) {
        printf("%s", a[i]);/*outout the array*/
    }
}

}

  • 写回答

1条回答 默认 最新

  • 快乐鹦鹉 2022-12-13 22:31
    关注

    if (a[j], a[j + 1] > 0) {
    改为
    if(strcmp(a[j],a[j+1]) > 0)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 12月24日
  • 已采纳回答 12月16日
  • 创建了问题 12月13日

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大