Answer the question
In order to leave comments, you need to log in
How to implement this cycle correctly?
I just started learning C++: I'm getting acquainted with cycles, and the following problem arose, I give a piece of code:
for(year = 2014; year <=2114; year++)//допустим, есть некоторое значение года, стартуем с 2014 до 2114
{
int ostYear = year%10;//находим остаток от года
if(ostDay == ostYear || ostMonth == ostYear);// если остаток от года совпадает с остатком от дня или месяца (они были объявлены ранее), то нужно вывести этот год, если нет - продолжить поиск
cout<<year;
Answer the question
In order to leave comments, you need to log in
Extra semicolon:
if(ostDay == ostYear || ostMonth == ostYear);
^^^^^
int minN = std::min(remDay, remMonth);
int maxN = std::max(remDay, remMonth);
for(year = 201; year <=211; year++)
{
cout << year << MinN << '\n' << year << maxN;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question