| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 331 人关注过本帖
标题:怎么输出?
只看楼主 加入收藏
dreamhouse
Rank: 1
等 级:新手上路
帖 子:107
专家分:7
注 册:2011-12-16
结帖率:59.46%
收藏
已结贴  问题点数:2 回复次数:2 
怎么输出?
#include<iostream>
void main()
{
    int month=1;
        char *season=NULL;
        switch(month){
        case 12:
        case 1:
        case 2:
            season="winter";
            break;
        case 3:
        case 4:
        case 5:
            season="spring";
            break;
        case 6:
        case 7:
        case 8:
            season="summer";
            break;
        case 9:
        case 10:
        case 11:
            season="autumn";
            break;
        printf("april is in the %s\n " ,season);
        default:
            printf("bog month");
            
        }
        
}
搜索更多相关主题的帖子: spring void include autumn summer 
2012-12-21 17:08
daniel_
Rank: 5Rank: 5
等 级:职业侠客
帖 子:212
专家分:307
注 册:2012-11-13
收藏
得分:1 
.........
2012-12-21 17:23
cwds
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:23
专家分:134
注 册:2012-6-17
收藏
得分:1 
#include<stdio.h>
int main()    //不建议用void main
{
    int month=1;
        char *season=NULL;
        switch(month){
        case 12:
        case 1:
        case 2:
            season="winter";
            break;
        case 3:
        case 4:
        case 5:
            season="spring";
            break;
        case 6:
        case 7:
        case 8:
            season="summer";
            break;
        case 9:
        case 10:
        case 11:
            season="autumn";
            break;
        default:
            printf("bog month");
            
        }
        printf("april is in the %s\n " ,season);    //放这就ok了
        return 0;
}
因为你那个版本的printf("april is in the %s\n " ,season);这句是不会被执行的
2012-12-21 17:27
快速回复:怎么输出?
数据加载中...
 
   



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

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