Click here to Skip to main content
15,943,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

C++
#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;
}
Posted
Updated 11-Jul-16 19:17pm
v2
Comments
PIEBALDconsult 12-Jul-16 1:12am    
Please use "Improve question" to add more detail and context.

1 solution

You may want to replace
C++
if(s[i]=='w')
{
    break;
    check=1;
}

with
C++
if(s[i]=='w')
{
    check=1;
    break;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900