月和周计数..... [英] Month and week counting.....
本文介绍了月和周计数.....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
输入:4周
输出:52;
输入:30个月11.
输出:11;
这一年被认为是2016.But我的程序没有工作几周......检查变量的值总是保持0..help请。
我尝试了什么:
input:4 of weeks
output: 52;
input:30 of month 11.
output:11;
the year is considered 2016.But my program does not working for weeks..the value of check variable always remains 0..help please.
What I have tried:
#include <iostream>
#include
#define pii pair<int>
using namespace std;
int main()
{
long long n;
string s;
while(getline(cin,s))
{
int len=s.size();
int number=0;int check=0;
int i=0;
while(s[i]!=' ')
{
int digit=s[i]-'0';
number*=10;
number+=digit;
i++;
}
string ss;
for(;i<len;i++)>
{
if(s[i]=='w')
{
break;
check=1;
}
}
if(check==1) //here value of check is always remains 0
{ // what's the problem cann't understand.
if(number>=5 and number<=7)
cout<<"53\n";
else if(number>=2 and number<=4)
cout<<"52\n";
else
cout<<"51\n";
}
else{
if(number<30)
cout<<"12\n";
if(number==30)
cout<<"11\n";
else if(number==31)
{
cout<<"7\n";
}
}
// cout<<ss<<endl;
}
// {
// bool row[n];
// bool col[n]; //asphalting roads code
// memset(row,0,sizeof row);
// memset(col,0,sizeof col);
// map<pii,int>m;
// //int road[n][n];
// int x,y;
// for(int i=1;i<=n*n;i++)
// {
// cin>>x>>y;;
// int b=make_pair(x,y);
// m[x]=1;
// //road[x-1][y-1]=1;
//
// }
// int day=1;
// int size=m.size();
// for(map<int,int>::iterator it=m.begin();it!=m.end();it++)
// {
// x=it->first;
// y=it->second;
// if(row[x-1]==0 and col[y-1]==0)
// cout<<day<<" ";
// else if(row[x-1]==0 and col[y-1]==0 and day==size-1)
// cout<<day<<"\n";
// day++;
//
// }
// for(int i=1;i<=n;i++)
// {
// for(int j=1;j<=n;j++)
// {
// if(road[i][j]==1)
// {
// if(row[i]==0 and col[j]==0)
// {
// cout<<day<<" ";
// }
// day++;
// }
// }
// }
//cout << "Hello world!" << endl;
return 0;
}
推荐答案
您可能想要替换
You may want to replace
if(s[i]=='w')
{
break;
check=1;
}
with
with
if(s[i]=='w')
{
check=1;
break;
}
这篇关于月和周计数.....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文