| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1428 人关注过本帖
标题:为什么这个程序不出结果
只看楼主 加入收藏
嗯enen
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2020-3-17
结帖率:0
收藏
已结贴  问题点数:20 回复次数:3 
为什么这个程序不出结果
#include <stdio.h>
int main()
{
    int a,b,c,d;
    printf("请输入三个正数:");
    scanf("%d%d%d",a,b,c);
    d=a%10;
    printf("%d",d);
    if(d==1)
    {
        switch(b){
            case 1:printf("%dst January %d",a,c+1900);break;
            case 2:printf("%dst February %d",a,c+1900);break;
            case 3:printf("%dst March %d",a,c+1900);break;
            case 4:printf("%dst April %d",a,c+1900);break;
            case 5:printf("%dst May %d",a,c+1900);break;
            case 6:printf("%dst June %d",a,c+1900);break;
            case 7:printf("%dst July %d",a,c+1900);break;
            case 8:printf("%dst August %d",a,c+1900);break;
            case 9:printf("%dst September %d",a,c+1900);break;
            case 10:printf("%dst October %d",a,c+1900);break;
            case 11:printf("%dst November %d",a,c+1900);break;
            case 12:printf("%dst December %d",a,c+1900);break;
            }
    }else if(d==2)
    {
            switch(b){
            case 1:printf("%dnd January %d",a,c+1900);break;
            case 2:printf("%dnd February %d",a,c+1900);break;
            case 3:printf("%dnd March %d",a,c+1900);break;
            case 4:printf("%dnd April %d",a,c+1900);break;
            case 5:printf("%dnd May %d",a,c+1900);break;
            case 6:printf("%dnd June %d",a,c+1900);break;
            case 7:printf("%dnd July %d",a,c+1900);break;
            case 8:printf("%dnd August %d",a,c+1900);break;
            case 9:printf("%dnd September %d",a,c+1900);break;
            case 10:printf("%dnd October %d",a,c+1900);break;
            case 11:printf("%dnd November %d",a,c+1900);break;
            case 12 :printf("%dnd December %d",a,c+1900);break;
        }
    }else if(d==3)
    {
            switch(b){
            case 1:printf("%drd January %d",a,c+1900);break;
            case 2:printf("%drd February %d",a,c+1900);break;
            case 3:printf("%drd March %d",a,c+1900);break;
            case 4:printf("%drd April %d",a,c+1900);break;
            case 5:printf("%drd May %d",a,c+1900);break;
            case 6:printf("%drd June %d",a,c+1900);break;
            case 7:printf("%drd July %d",a,c+1900);break;
            case 8:printf("%drd August %d",a,c+1900);break;
            case 9:printf("%drd September %d",a,c+1900);break;
            case 10:printf("%drd October %d",a,c+1900);break;
            case 11:printf("%drd November %d",a,c+1900);break;
            case 12:printf("%drd December %d",a,c+1900);break;
        }
    }else {
            switch(b){
            case 1:printf("%dth January %d",a,c+1900);break;
            case 2:printf("%dth February %d",a,c+1900);break;
            case 3:printf("%dth March %d",a,c+1900);break;
            case 4:printf("%dth April %d",a,c+1900);break;
            case 5:printf("%dth May %d",a,c+1900);break;
            case 6:printf("%dth June %d",a,c+1900);break;
            case 7:printf("%dth July %d",a,c+1900);break;
            case 8:printf("%dth August %d",a,c+1900);break;
            case 9:printf("%dth September %d",a,c+1900);break;
            case 10:printf("%dth October %d",a,c+1900);break;
            case 11:printf("%dth November %d",a,c+1900);break;
            case 12:printf("%dth December %d",a,c+1900);break;
    }
   
   

}
}
搜索更多相关主题的帖子: printf case 结果 switch break 
2020-03-17 14:49
叶纤
Rank: 8Rank: 8
等 级:禁止访问
威 望:1
帖 子:658
专家分:848
注 册:2019-11-22
收藏
得分:7 
  scanf("%d%d%d",a,b,c);
改为
  scanf("%d%d%d",&a,&b,&c);

把学习时间浪费在混坛上是傻瓜行为,更何况自己的水平连一两都没到。
2020-03-17 16:05
return_0
Rank: 8Rank: 8
来 自:五维空间
等 级:禁止访问
威 望:3
帖 子:512
专家分:838
注 册:2020-1-28
收藏
得分:7 
好晕啊,用for和数组可以把代码缩短很多呀。

2020-03-17 19:46
hbccc
Rank: 5Rank: 5
等 级:职业侠客
威 望:5
帖 子:108
专家分:315
注 册:2020-2-18
收藏
得分:7 
我也晕  scanf 变量要加&
2020-03-17 20:51
快速回复:为什么这个程序不出结果
数据加载中...
 
   



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

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