标题:为什么输出一堆乱码 求助
取消只看楼主
新手一只
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2019-7-26
结帖率:0
已结贴  问题点数:20 回复次数:2 
为什么输出一堆乱码 求助

#include <stdio.h>
#include <stdlib.h>

int main()
{   
    int i;
    int z[4];
        char w[4];
    int x[4];
    for(i = 0;i < 4; i++){
        scanf("%c",&w[i]);
        x[i]=(w[i]-64);

        switch(x[i]){
        case 1:
          z[i] = 8;
          break;
        case 2:
          z[i] = 8;
          break;
        case 3:
          z[i] = 12;
          break;
        case 4:
          z[i] = 2;
          break;
        case 5:
          z[i] = 2;
          break;
        case 6:
          z[i] = 3;
          break;
        case 7:
          z[i] = 14;
         break;
        case 8:
          z[i] = 15;
          break;
        case 9:
          z[i] = 6;
          break;
        case 10:
          z[i] = 14;
          break;
        case 11:
          z[i] = 14;
          break;
        case 12:
          z[i] = 13;
          break;
        case 13:
          z[i] = 1;
          break;
        case 14:
          z[i] = 19;
          break;
        case 15:
          z[i] = 16;
          break;
        case 16:
          z[i] = 19;
          break;
        case 17:
          z[i] = 3;
          break;
        case 18:
          z[i] = 1;
          break;
        case 19:
          z[i] = 11;
          break;
        case 20:
          z[i] = 3;
          break;
        case 21:
          z[i] = 19;
          break;
        case 22:
          z[i] = 20;
          break;
        case 23:
          z[i] = 22;
          break;
        case 24:
          z[i] = 3;
          break;
        case 25:
          z[i] = 13;
          break;
        case 26:
          z[i] = 6;
          break;
    }
        }      
    printf("%d\t",z[1]);
    printf("%d\t",z[2]);
    printf("%d\t",z[3]);
    printf("%d\t",z[4]);
        system("pause");
        return 0;
}
输出结果只有第二个正常 怎么办
搜索更多相关主题的帖子: 输出 int case break printf 
2019-07-26 11:26
新手一只
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2019-7-26
得分:0 
回复 3楼 wufuzhang
谢 大佬
可是我无论输入什么第四个数值总是29
2019-07-26 16:48
新手一只
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2019-7-26
得分:0 
回复 5楼 rjsp
WOW 谢大佬
2019-07-26 17:24



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-496047-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.154067 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved