Home > Back-end >  What to do, I am a small white
What to do, I am a small white

Time:10-09

CodePudding user response:

This is very simple, input use cin, condition judgment with the if

CodePudding user response:

The building Lord, where are you this?

CodePudding user response:

#include

using namespace std;

Int main () {
Int year;
Cin & gt;> Year;
If (year & lt; 1900 | | year> 2200)
Cout & lt; <"Error" & lt; Else if (year %==0 400)
Cout & lt; <"Yes" & lt; Else if (year %==0 100)
Cout & lt; <"No" & lt; Else if (year % 4==0)
Cout & lt; <"Yes" & lt; The else
Cout & lt; <"No" & lt;
return 0;
}

CodePudding user response:

reference 1st floor qq_46221910 response:
this is very simple, input conditions with cin, determine if

But if the input is not legitimate, the output error, I can't find this condition, I input output is 1984.1 yes

CodePudding user response:

reference 燚 recognition response: 3/f
# include

using namespace std;

Int main () {
Int year;
Cin & gt;> Year;
If (year & lt; 1900 | | year> 2200)
Cout & lt; <"Error" & lt; Else if (year %==0 400)
Cout & lt; <"Yes" & lt; Else if (year %==0 100)
Cout & lt; <"No" & lt; Else if (year % 4==0)
Cout & lt; <"Yes" & lt; The else
Cout & lt; <"No" & lt;
return 0;
}

Mainly input illegal zha write the condition I input output yes. 1984.1 he should just correct output error

CodePudding user response:

reference 燚 recognition response: 3/f
# include

using namespace std;

Int main () {
Int year;
Cin & gt;> Year;
If (year & lt; 1900 | | year> 2200)
Cout & lt; <"Error" & lt; Else if (year %==0 400)
Cout & lt; <"Yes" & lt; Else if (year %==0 100)
Cout & lt; <"No" & lt; Else if (year % 4==0)
Cout & lt; <"Yes" & lt; The else
Cout & lt; <"No" & lt;
return 0;
}

Mainly input illegal zha write the condition I input output yes. 1984.1 he should just correct output error

CodePudding user response:

This is because the definition of type int, input 1984.1, actually read only to 1984, if you add in an input statement to double, you will find that no longer need to input, read a value of 0.1, to deal with this kind of situation that can be to define the year into a double, then priority to determine whether the decimal part is zero, however, according to this logic also need interpretation will appear input "1984 sfdasdv" behind this brought something by randomly, so you in trouble, I feel the problem should not need to do this step, a practical application is can limit input, so suggest don't need to be here
  • Related