12或mes3399或任何,c++,boolean,codeblocks,C++,Boolean,Codeblocks" /> 12或mes3399或任何,c++,boolean,codeblocks,C++,Boolean,Codeblocks" />

使用使用bool c+;验证日期的程序+;? 对于C++编程,我是新手,对布尔运算没有做任何事情。我在这个节目中犯了哪些错误?提前谢谢 //INPUT: Enter a date in the format DDMMYYYY, for example 14102014 //OUTPUT: Says if the date is correct or no #include <iostream> using namespace std; int main() { bool incorrecta; cout << "ENTER A DATE:" << endl; int data; cin>> data; int any= data%10000; int dmes= data/10000; int dia= dmes/100; int mes= dmes%100; if (mes>12 or mes<1) incorrecta=true; else if (any>3399 or any<100) incorrecta=true; else if ((dia<1 or dia>31) and (mes==1 or mes==5 or mes==3 or mes==7 or mes==8 or mes==10 or mes==12)) incorrecta=true; else if ((dia<1 or dia>30) and (mes==4 or mes==6 or mes==9 or mes==11)) cout<< "THE DATE IS INCORRECT"<< endl; else if (mes==2){ if(any%4==0 and (any%100!=0 or any%400==0)) cout <<"THE DATE IS CORRECT" <<endl; else incorrecta=true; } if (incorrecta==true) cout<< "THE DATE IS INCORRECT"<< endl; else cout <<"THE DATE IS CORRECT" <<endl; return 0; } //输入:以DDMMYYYY格式输入日期,例如14102014 //输出:表示日期是否正确 #包括 使用名称空间std; int main() { 布尔不正确; cout数据; int any=数据%10000; int dmes=数据/10000; 内径=dmes/100; int mes=dmes%100; 如果(mes>12或mes3399或任何

使用使用bool c+;验证日期的程序+;? 对于C++编程,我是新手,对布尔运算没有做任何事情。我在这个节目中犯了哪些错误?提前谢谢 //INPUT: Enter a date in the format DDMMYYYY, for example 14102014 //OUTPUT: Says if the date is correct or no #include <iostream> using namespace std; int main() { bool incorrecta; cout << "ENTER A DATE:" << endl; int data; cin>> data; int any= data%10000; int dmes= data/10000; int dia= dmes/100; int mes= dmes%100; if (mes>12 or mes<1) incorrecta=true; else if (any>3399 or any<100) incorrecta=true; else if ((dia<1 or dia>31) and (mes==1 or mes==5 or mes==3 or mes==7 or mes==8 or mes==10 or mes==12)) incorrecta=true; else if ((dia<1 or dia>30) and (mes==4 or mes==6 or mes==9 or mes==11)) cout<< "THE DATE IS INCORRECT"<< endl; else if (mes==2){ if(any%4==0 and (any%100!=0 or any%400==0)) cout <<"THE DATE IS CORRECT" <<endl; else incorrecta=true; } if (incorrecta==true) cout<< "THE DATE IS INCORRECT"<< endl; else cout <<"THE DATE IS CORRECT" <<endl; return 0; } //输入:以DDMMYYYY格式输入日期,例如14102014 //输出:表示日期是否正确 #包括 使用名称空间std; int main() { 布尔不正确; cout数据; int any=数据%10000; int dmes=数据/10000; 内径=dmes/100; int mes=dmes%100; 如果(mes>12或mes3399或任何,c++,boolean,codeblocks,C++,Boolean,Codeblocks,可能您所需要的只是在第一个之前放置incorrecta=false;,如果,那么变量被正确初始化。如果没有满足任何条件,那么在最后它仍然是false。程序应该做什么?程序在做什么?您能减少代码以便我们只需要观看吗可能会出错的行?是否也可以用英语?您的打印输出对这里的人没有帮助。您遇到了编译器错误、运行时错误或逻辑错误。对不起,我的水晶球坏了:-)是的,那你有什么问题吗?替换第一个coutSorry,我已经用英语翻译了couts,这完全是错误的逻辑,程序总是说“日期不正确”谢谢!!错误就是你说的。

可能您所需要的只是在第一个
之前放置
incorrecta=false;
,如果
,那么变量被正确初始化。如果没有满足任何条件,那么在最后它仍然是false。

程序应该做什么?程序在做什么?您能减少代码以便我们只需要观看吗可能会出错的行?是否也可以用英语?您的打印输出对这里的人没有帮助。您遇到了编译器错误、运行时错误或逻辑错误。对不起,我的水晶球坏了:-)是的,那你有什么问题吗?替换第一个
coutSorry,我已经用英语翻译了couts,这完全是错误的逻辑,程序总是说“日期不正确”谢谢!!错误就是你说的。现在程序工作正常:)