Results 1 to 9 of 9

Thread: [C++]

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User PlamenPenchev's Avatar
    Join Date: Mar:2009
    Location: -
    Posts: 627

    [C++]

    . , 31.7.2007 1.8.2007, " ". , , , . , - , , .
    .
    Code:
    #include <iostream>
    #include <conio.h>
    #include <cmath>
    using namespace std;
    int main()
    {
        int m,d,year;
        cin>>d>>m>>year;
        if(m>12) cout<<"Nevaliden mesec";
        if(m==12&&d==31) cout<<"1.1."<<++year;
        else {
                if(year%4==0&&year%100!=0||year%400==0){
        if(m==1||m==3||m==5||m==7||m==8||m==10||m==12)
        switch(d)
        {
                 case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:case 29:case 30:{d++;cout<<d<<"."<<m<<"."<<year;};break;
                 case 31:cout<<1<<"."<<++m<<"."<<year;break;
                 default:cout<<"Neveliden den";break;
                 };
                 if(m==2){
                 switch(d)
                 {
                  case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:{d++;cout<<d<<"."<<m<<"."<<year;};break;
                  case 29:cout<<1<<"."<<++m<<"."<<year;break;
                  default:cout<<"Neveliden den";break;
                  };}
                  if(m==4||m==6||m==9||m==11)
                  switch(d)
                  {
                           case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:case 29:{d++;cout<<d<<"."<<m<<"."<<year;};break;
                 case 30:cout<<1<<"."<<++m<<"."<<year;break;
                 default:cout<<"Neveliden den";break;}}
        else {
        switch(d)
                 {
                 case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:case 29:case 30:{d++;cout<<d<<"."<<m<<"."<<year;};break;
                 case 31:cout<<1<<"."<<++m<<"."<<year;break;
                 default:cout<<"Neveliden den";break;
                 };
                 if(m==2)
                 switch(d)
                 {
                  case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:{d++;cout<<d<<"."<<m<<"."<<year;};break;
                  case 28:cout<<1<<"."<<m++<<"."<<year;break;
                  default:cout<<"Neveliden den";break;
                  };
                  if(m==4||m==6||m==9||m==11)
                  switch(d)
                  {
                           case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:case 29:{d++;cout<<d<<"."<<m<<"."<<year;};break;
                 case 30:cout<<1<<"."<<++m<<"."<<year;break;
                 default:cout<<"Neveliden den";break;};}}
                 getch();
                 return 0;
                 }

  2. #2
    Nuclear's Avatar
    Join Date: Sep:2004
    Location: , . ()
    Posts: 3,352
    , , , if, if. m=7 , m=7 m=8 if.
    if-o else if return (a ).

    case-o 1 30? - if (d>0 && d<31) .
    . HWBG !

  3. #3
    Registered User PlamenPenchev's Avatar
    Join Date: Mar:2009
    Location: -
    Posts: 627
    .

  4. #4
    ɐ-əpoɔᴉu⋂ ɐ ə anrieff's Avatar
    Join Date: Apr:2004
    Location: Sofia
    Posts: 8,448
    , ():

    Code:
    d++;
    if (!validDate()) {
        d = 1;
        m++;
        if (!validDate()) {
            m = 1;
            year++;
        }
    }
    validDate() ( 1-12 ).
    - .
    , . .
    "640K ught to be enough for anybody" - Bill Gates, 1981
    ::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel

  5. #5
    Registered User PlamenPenchev's Avatar
    Join Date: Mar:2009
    Location: -
    Posts: 627
    .

  6. #6
    ɐ-əpoɔᴉu⋂ ɐ ə anrieff's Avatar
    Join Date: Apr:2004
    Location: Sofia
    Posts: 8,448
    validDate().
    d.m.year , d, m year. ( ) :
    Code:
    bool validDate() {
        if (m < 1 || m > 12) return false;
        if (d < 1) return false;
        if () if (d > 31) return false;
        if () ...
        ...
    }
    .
    . ( 31.10.2010 32.10.2010), 1, . , 1 .
    , . .
    "640K ught to be enough for anybody" - Bill Gates, 1981
    ::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel

  7. #7
    Registered User PlamenPenchev's Avatar
    Join Date: Mar:2009
    Location: -
    Posts: 627
    . .

  8. #8
    Ronnie James Dio Snow's Avatar
    Join Date: Jun:2005
    Location:
    Posts: 8,221
    , - [cde][/cde] ? , ...

    Quote Originally Posted by Pesho View Post
    off, , . IDE editor
    Note taken!
    Last edited by Snow; 20th November 2010 at 10:13.
    MSI B550i Gaming Edge Wifi | Ryzen 9 5900X [Thermalright AXP-100C65 + Noctua A9x14] | G.Skill 2x16GB F4-3200C16Q-32GTZR | AMD RX 6800XT | EVO970 500GB + EVO850 250GB + EVO850 500GB + DS119j | Corsair SF750 Platinum | ASUS MG279Q | Razer DeathAdder V2 Pro | Keychron K6 Modded | SligerSM550

  9. #9
    Pesho's Avatar
    Join Date: Nov:2001
    Location: Sofia
    Posts: 5,169
    Quote Originally Posted by Snow View Post
    , - [cde][/cde] ? , ...
    off, , . IDE editor
    , !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |