別のコードを使用してこのコードにdo/whileループを追加する必要があります。別の!= n。問題は、私はdo/whileループには大変恐ろしいです。どこにすべてを置くべきか分かりません。それはスイッチ自体の前にあるでしょうか?または、入力モジュール全体の前に?do/whileループを追加する
//Compiler Directives
#include<iostream>
#include<cstdlib>
using namespace std;
//Constant Declarations
const int LOWERBOUND = 400;
const int UPPERBOUND = 2400;
//Main Body
int main(){
//Local Identifiers
int year, leapCode;
//Input Module
cout<<"Please enter a year in the range 400 to 2400\t";
cin>>year;
//Process Module
if ((year >= LOWERBOUND)&& (year <= UPPERBOUND)){
if (year%4!=0)
leapCode = 1;
else
if (year%100!=0)
leapCode = 2;
else
if (year%400!=0)
leapCode = 3;
else
leapCode = 4;
switch(leapCode){
case 1:
cout<<"The year "<<year<<" is not a leap year\n";
break;
case 2:
cout<<"The year "<<year<<" is a leap year\n";
break;
case 3:
cout<<"The year "<<year<<" is a century year but not a leap year\n";
break;
case 4:
cout<<"The year "<<year<<" is a leap century year";
break;
} //end switch
}
else
cout<<"The year is out of range\n";
system("PAUSE");
return 0;
}
少なくとも何かを試してください – pm100
SO上の人は通常あなたの宿題をしません。 –
あなたが何をしなければならないのかを一度、そして多分何度もあなた自身に尋ねてください。それはあなたにヒントを与えるはずです。 –