| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 542 人关注过本帖
标题:看我写的程序
只看楼主 加入收藏
hanshengchua
Rank: 1
等 级:禁止访问
威 望:2
帖 子:174
专家分:0
注 册:2006-5-8
收藏
 问题点数:0 回复次数:4 
看我写的程序
#include <iostream>
using namespace std;
class out_month
{
int month;
cout<<"Tell me a month number:";
cin>>month;
void days()
{
if(month<=7&&month!=2)
{
if(month%2==0)
cout<<"Month has 30 days"<<endl;
else
cout<<"Month has 31 days"<<endl;
}
else
{
if(month%2==0&&month!=2)
cout<<"Month has 31 days"<<endl;
else
{
if(month!=2)
cout<<"Month has 30 days"<<endl;
else
cout<<"Month has 28 or 29 days"<<endl;
}
}
}

};
int main()
{
out_month S1;
S1.days();
system("pause");
return 0;
}
编译的时候有错误,哪里出错了???
2006-05-09 22:47
guang
Rank: 4
来 自:广东深圳
等 级:贵宾
威 望:13
帖 子:1414
专家分:285
注 册:2006-4-3
收藏
得分:0 

#include <iostream>
using namespace std;
class out_month
{
int month;
public:
out_month()
{
cout<<"Tell me a month number:";
cin>>month;
}

void days()
{
if(month<=7&&month!=2)
{
if(month%2==0)
cout<<"Month has 30 days"<<endl;
else
cout<<"Month has 31 days"<<endl;
}
else
{
if(month%2==0&&month!=2)
cout<<"Month has 31 days"<<endl;
else
{
if(month!=2)
cout<<"Month has 30 days"<<endl;
else
cout<<"Month has 28 or 29 days"<<endl;
}
}
}

};
int main()
{
out_month S1;
S1.days();
system("pause");
return 0;
}
这样可以了吧!


不相信未作牺牲竟先可拥有,只相信靠双手找到我的欲求!!
我的博客:http://liao5930.blog.
2006-05-09 23:08
心动音符
Rank: 1
等 级:禁止访问
威 望:1
帖 子:832
专家分:0
注 册:2005-9-15
收藏
得分:0 

没有入口啊


2006-05-11 14:15
不得不编
Rank: 1
等 级:新手上路
帖 子:65
专家分:0
注 册:2006-4-4
收藏
得分:0 

在类里漏了~PUBLIC: 默认为PRIVATE的了

2006-05-11 23:26
虫虫飞ya飞
Rank: 1
等 级:新手上路
帖 子:122
专家分:0
注 册:2005-11-28
收藏
得分:0 

感觉if语句饶的好乱咯,
if(month<=7&&month!=2&&month%2==0)
{
cout<<"Month has 30 days"<<endl;
else
cout<<"Month has 31 days"<<endl;
}

else

if(month==2&&month%2==0){

cout<<"Month has 28 days"<<endl;
else
cout<<"Month has 29 days"<<endl;
}
这样可行呢


2006-05-12 15:58
快速回复:看我写的程序
数据加载中...
 
   



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

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