#include <iostream>
using namespace std;
int main()
{
setlocale(LC_ALL, "rus");
int enterNumber = 0;
cout << "Введите целое число (от 1 до 9999): ";
cin >> enterNumber;
// проверяем входит ли введенное число в заданный диапазон
if (enterNumber <= 0 ||enterNumber > 9999)
cout << "Число не входит в диапазон от 1 до 9999!\n";
else // если да - приступаем к выводу на экран
{
cout << "\nВы ввели: ";
// чтобы добраться до первой цифры в введенном числе
// (если оно четырехзначное), надо это число поделить
// на 1000 и взять от него остаток от деления на 10
// например 8 888 / 1000 = 8 (888 тысячные отбрасываются
// т.к. введенное число типа int), далее 8 % 10 = 8
// так же не ошибитесь с оператором == (равно)
if ((enterNumber / 1000) % 10 == 1) cout << "Одна тысяча ";
else if ((enterNumber / 1000) % 10 == 2) cout << "Две тысячи ";
else if ((enterNumber / 1000) % 10 == 3) cout << "Три тысячи ";
else if ((enterNumber / 1000) % 10 == 4) cout << "Четыре тысячи ";
else if ((enterNumber / 1000) % 10 == 5) cout << "Пять тысяч ";
else if ((enterNumber / 1000) % 10 == 6) cout << "Шесть тысяч ";
else if ((enterNumber / 1000) % 10 == 7) cout << "Семь тысяч ";
else if ((enterNumber / 1000) % 10 == 8) cout << "Восемь тысяч ";
else if ((enterNumber / 1000) % 10 == 9) cout << "Девять тысяч ";
if ((enterNumber / 100) % 10 == 1) cout << "сто ";
else if ((enterNumber / 100) % 10 == 2) cout << "двести ";
else if ((enterNumber / 100) % 10 == 3) cout << "триста ";
else if ((enterNumber / 100) % 10 == 4) cout << "четыреста ";
else if ((enterNumber / 100) % 10 == 5) cout << "пятьсот ";
else if ((enterNumber / 100) % 10 == 6) cout << "шестьсот ";
else if ((enterNumber / 100) % 10 == 7) cout << "семьсот ";
else if ((enterNumber / 100) % 10 == 8) cout << "восемьсот ";
else if ((enterNumber / 100) % 10 == 9) cout << "девятьсот ";
if ((enterNumber / 10) % 10 == 1)
{
if (enterNumber % 10 == 0) cout << "десять долларов";
else if (enterNumber % 10 == 1) cout << "одинадцать долларов";
else if (enterNumber % 10 == 2) cout << "двенадцать долларов";
else if (enterNumber % 10 == 3) cout << "тринадцать долларов";
else if (enterNumber % 10 == 4) cout << "четырнадцать долларов";
else if (enterNumber % 10 == 5) cout << "пятнадцать долларов";
else if (enterNumber % 10 == 6) cout << "шестнадцать долларов";
else if (enterNumber % 10 == 7) cout << "семнадцать долларов";
else if (enterNumber % 10 == 8) cout << "восемнадцать долларов";
else if (enterNumber % 10 == 9) cout << "девятнадцать долларов";
}
if ((enterNumber / 10) % 10 == 2) cout << "двадцать ";
else if ((enterNumber / 10) % 10 == 3) cout << "тридцать ";
else if ((enterNumber / 10) % 10 == 4) cout << "сорок ";
else if ((enterNumber / 10) % 10 == 5) cout << "пятьдесят ";
else if ((enterNumber / 10) % 10 == 6) cout << "шестьдесят ";
else if ((enterNumber / 10) % 10 == 7) cout << "семьдесят ";
else if ((enterNumber / 10) % 10 == 8) cout << "восемьдесят ";
else if ((enterNumber / 10) % 10 == 9) cout << "девяносто ";
if ((enterNumber / 10) % 10 != 1)
{
if (enterNumber % 10 == 0) cout << "долларов";
else if (enterNumber % 10 == 1) cout << "один доллар";
else if (enterNumber % 10 == 2) cout << "два доллара ";
else if (enterNumber % 10 == 3) cout << "три доллара ";
else if (enterNumber % 10 == 4) cout << "четыре доллара ";
else if (enterNumber % 10 == 5) cout << "пять долларов ";
else if (enterNumber % 10 == 6) cout << "шесть долларов ";
else if (enterNumber % 10 == 7) cout << "семь долларов ";
else if (enterNumber % 10 == 8) cout << "восемь долларов ";
else cout << "девять долларов ";
}
}
cout << endl << endl;
return 0;
}
LIKE SO…
#include “pch.h”
#include
using namespace std;
int main()
{
setlocale(LC_ALL,”RUS”);
int a, b, c, d;
cout << "Введите 2 number" <> a >> b;
cout << "Введите результат сложения двух чисел" <> d;
c = a * b;
if (d == c)
{
cout << "Отв Верн" << endl;
}
else if(d!=c)
{
cout << "Вы ввели не правильный ответ" << endl;
cout << "Правильный ответ=" << c << endl;
}
}
#include
using namespace std;
int main() {
setlocale(LC_ALL, “russian”);
int first = 0;
int second = 0;
int third= 0;
int d = 0;
cout <> first;
cout <> second;
cout <> d;
third = first * second;
if (d == third) {
cout << "Ответ верный" << endl;
}
else if (d != third) {
cout << "Ответ не правильный" << endl;
cout << "Правильный ответ=" << third << endl;
}
system("pause");
return 0;
#include
using namespace std;
void main() {
setlocale(LC_ALL, “ru”);
int a = 0, b = 0, otvet = 0;
cout << "Введите два числа\n" <> a;
cout <> b;
cout <> otvet;
if (a * b == otvet)
{
cout << "\nВы ответили правильно. Composition " << a << " and " << b << " will be equal to " << a * b;
}
else if (a * b != otvet) {
cout << "\nК сожалению, you answered incorrectly. Result product " << a << " and " << b << " is equal to " << a * b;
}
cout << "\n\n\n\n\n\n";
}
About scoring four-digit number:
int main()
{
setlocale(LC_ALL, “rus”);
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
start :
int ch,your,today,of the,ed;
cout < 9999: “;
cin >> ch;
if (ch > 9999)
{
cout << "Сказал же, не больше! ";
goto start;
}
if (ch ==0)
{
cout << "Бомжара))\n";
goto start;
}
if (ch <0)
{
cout << "Долги? I sympathize)\n";
goto start;
}
else
{
= ch / 1000;
switch (your)
{
case 1:
cout << "Одна тысяча ";
break;
case 2:
cout << "Две тысячи ";
break;
case 3:
cout << "Три тысячи ";
break;
case 4:
cout << "Четыре тысячи ";
break;
case 5:
cout << "Пять тысяч ";
break;
case 6:
cout << "Шесть тысяч ";
break;
case 7:
cout << "Семь тысяч ";
break;
case 8:
cout << "Восемь тысяч ";
break;
case 9:
cout << "Девять тысяч ";
break;
case 0:
cout << "";
break;
}
said ch = % 1000;
today / = 100;
switch (today)
{
case 1:
cout << "сто ";
break;
case 2:
cout << "двести ";
break;
case 3:
cout << "триста ";
break;
case 4:
cout << "четыреста ";
break;
case 5:
cout << "пятьсот ";
break;
case 6:
cout << "шестьсот ";
break;
case 7:
cout << "семьсот ";
break;
case 8:
cout << "восемьсот ";
break;
case 9:
cout << "девятьсот ";
break;
case 0:
cout << "";
break;
}
of = ch % 1000;
of = the % 100;
of = the / 10;
switch (of the)
{
case 1:
{
of = ch % 1000;
of = the % 100;
if (of == 10)
cout << "десять";
if (of == 11)
cout << "одинадцать долларов";
if (of == 12)
cout << "двенадцать долларов";
if (of == 13)
cout << "тринадцать долларов";
if (of == 14)
cout << "четырнадцать долларов";
if (of == 15)
cout << "пятнадцать долларов";
if (of == 16)
cout << "шестнадцать долларов";
if (of == 17)
cout << "семнадцать долларов";
if (of == 18)
cout << "восемнадцать долларов";
if (of == 19)
cout << "девятнадцать долларов";
goto end;
break;
}
case 2:
cout << "двадцать ";
break;
case 3:
cout << "тридцать ";
break;
case 4:
cout << "сорок ";
break;
case 5:
cout << "пятьдесят ";
break;
case 6:
cout << "шестьдесят ";
break;
case 7:
cout << "семьдесят ";
break;
case 8:
cout << "восемьдесят ";
break;
case 9:
cout << "девяносто ";
break;
case 0:
cout << "";
break;
}
ed = ch % 1000 % 100 % 10;
switch (ed)
{
case 1:
cout << "один доллар";
break;
case 2:
cout << "два доллара";
break;
case 3:
cout << "три доллара";
break;
case 4:
cout << "четыре доллара";
break;
case 5:
cout << "пять долларов";
break;
case 6:
cout << "шесть долларов";
break;
case 7:
cout << "семь долларов";
break;
case 8:
cout << "восемь долларов";
break;
case 9:
cout << "девять долларов";
break;
case 0:
cout << "";
break;
}
end:
if (ch % 10 == 0) cout << " долларов";
cout << ".\n";
goto start;
}
}