#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;
}
1#include
2using namespace std;
3int main (){
4 setlocale (0,””);
5 int variable1 = 0;
6 variable_2 int = 0;
7 int variable 3 = 0;
8 cout<<"Введіть два цілих однозначних числа і результат їх множення:"<<endl;
9 cout<<"Введіть число 1"<>variable1;
11 cout<<"Введіть число 2"<>variable2;
13 cout<<"Введіть результат множення чисел 1 та 2"<>variable3;
15 if((variable1=10))
16 cout<<"Ви неправильно ввели чсло 1"<<endl;
17 if((variable2=10))
18 cout<<"Ви неправильно ввели чсло 2"<<endl;
19 if (variable1*variable2==variable3)
20 cout<<"Гаро множиш"<<endl;
21 if (variable1 * variable_2!=variable3)
22 cout<<"Помилка"<<endl;
23 return 0;
24}
line does not work 15 and 17 if I enter numbers, for example 0 and 10, and in response, writing 0, vybyvaet term 20. What is this code wrong ?
Обрати внимание if (variable1==10) – so it will be correctly, = Is the assignment symbol… You ask a condition that if the variable is 10, the same in the second if..
to enter the number you need to write is not cout (this conclusion), What а>>
You can always write in this order here:
if( 10 == vfriable1 ) ...
Then you'll never be wrong.
Useful habit.
1 Program end else cout << "девять долларов "; wrong. Decimal try to lead.
#include “stdafx.h”
#include
using namespace std;
int main()
{
setlocale(LC_ALL, “rus”);
int a, b;
int f;
cout <> a;
cout <> b;
cout << endl;
cout <> f;
if (f == a * b)
{
cout << "Ответ " << f << " is " << a << "*" << b << endl;
}
else
{
cout << "Ответ " << f << " not equal to " << a << "*" << b << endl;
}
cout << endl;
system("pause");
return 0;
}
somehow it was not displayed quite correctly, some pieces were cut out
#include
using namespace std;
int main()
{ setlocale(LC_ALL, “rus”);
cout << "проверка знаний на таблицу умножений" << endl;
int i, a, b, x; //create variables for work
cout << "введите первое число от 1 to 10 " <> a; //assign the entered result to a variable
cout << "введите второе число от 1 to 10 " <> b; //assign the entered result to variable b
x = a*b; // We multiply the entered data and write it to the variable x
cout << "Введите как вам кажется результат умножения " << a << " x " << b <> i; //we ask the user to enter the result and write it to the variable i
if (ix){ cout << "учите таблицу умножения, correct answer: " << x << endl; }//compare the results
else{ cout << "ВЕРНО!!! Вы знаете таблицу умножения "; }
system("pause");
return 0;}
#include
#include
#include
using namespace std;
int main(void)
{
setlocale(0, “”);
int a, b;
int c = 0;
cout <> a;
cout <> b;
cout <> c;
{
if (c == a*b)
cout << "Ваш ответ сходится с результатом калькулятора!" << endl;
else
cout << "Это неправильный ответ. Correct answer = " << a * b << endl;
}
system("pause");
return 0;
}
something CIN is overwritten in the code…
The forum editor corrupts the code – don't post the code here!
Honestly, I didn't understand the first problem…. For those who don't mind, please explain…
what is not clear? A task – enter a four-digit amount – the program displays it in words and with the correct ending of the name of the currency at the end – 1234 – one thousand two hundred thirty-four dollars
Wrote code for the first problem with an ATM.
The code turned out not so beautiful, as in the answer, but I wrote it myself, no prompts)
It seems to work, but was grateful, if “tested”..
No one here will look at the sheets of your code – the site is not for that.
Don't put your code here!
Why do so many people ignore it?:that they ask not to write the code here?))maybe they want,to be praised?
Don't want to – don't read. And don't be responsible for everyone. Ok?
I, for example, I'm looking at that, what others write.
Good,read,only code,spoils the forum editor(write) and that's how it is!
How long did it take to solve the problem??