#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;
}
Exist 3 I completed the task with this code:
#include
using namespace std;
int main ()
{
int a,b,c,summ;
eating;
eat" b;
if (a>=1 && a=1 && b<=9)
{
summ=a*b;
cout«"Введите ответ! : "«endl;
c;
if (c==summ)
{
cout«"Верно!"«endl;
} else {cout«"Вот верный ответ : "«summ;}
}
}
#include
using namespace std;
int main ()
{
int a,b,c,summ;
cin>>a;
cin>>b;
if (a>=1 && a=1 && b<=9)
{
summ=a*b;
cout<<"Введите ответ! : "<>c;
if (c==summ)
{
cout<<"Верно!"<<endl;
} else {cout<<"Вот верный ответ : "<<summ;}
}
}
Don't write code here!no one needs.
#include
#include
using namespace std;
int main()
{
short FirstChar;
short SecondChar;
short Answer;
cout << "Ведите два чила" <> FirstChar >> SecondChar;
cout << "Сколько будет " << FirstChar << " Multiply by " << SecondChar << "?" <> Answer;
if (Answer == FirstChar * SecondChar){
cout << "Верно! This number: " << Answer;
} else {
cout << "Неверно! Correct answer: " << FirstChar * SecondChar << endl;
}
return 0;
}
Don't post your attempts at experimenting with code here.. Nobody needs this! (and no one will watch it).
Comments are not for!
If you can't cope, ask questions in the comments.. Isn’t that what he writes under the assignment??
That's how it's written “who can't cope“, but not “who copes“? - feel the difference.
And it is written “ask questions in the comments“, but it’s not written “post your code in the comments“.
And, finally, editor site distorts C++ code, so it’s simply pointless to write it here, and no one will watch it.
I don't understand the solution to the first problem. I solved it, but the code turned out to be simply huge, twice as much as this. why in your code, when entering 4 significant numbers, at the first correct one (true) answer, the operation does not end and it does not simply issue “Две тысячи”, or “Девять тысяч”?
#include
using namespace std;
int main()
{ int a,b,much,value;
cout<<"enter two values"<>a>>b;
mult=a*b;
cout<<"enter your value"<>value;
if (mult==value)
cout<<"well-done";
else if(much!=value)
cout<<"you are wrong"<<much;
return 0;
}
Why are you writing this here??
You can't delete comments?I'm talking about the code!If someone uses uncensored language, it will be somehow deleted?
Only admin could do this.
He probably doesn’t need it. But it would be great,if the comments only contained useful information,there is a lot in them,what complements the site!
#include
using namespace std;
int main()
{
setlocale(LC_ALL, “rus”);
int a;
cout <> a;
int b;
cout <> b;
int c = a*b;
int d;
cout <> d;
if (c == d)
cout << "Правильный ответ!\n";
else
cout << "Вам еще надо поучится считать!\n";
system("pause");
}
This is how I solved the third problem:
Oops, something didn't come out right here, so I'll write it in the usual way:
#include
using namespace std;
int main() {
setlocale(LC_ALL, “rus”);
int num1 = 0;
int num2 = 0;
int answer = 0;
cout << "СЕЙЧАС МЫ ПРОВЕРИМ ВАС НА ЗНАНИЕ МАТЕМАТИКИ\n";
cout <> num1;
cout <> num2;
cout <> otvet;
if ((num1 * num2) == answer) {
cout <<"Вы правы, вот ход решения "<< num1<< " * " << num2 << " = " << otvet;
} else {
cout <<"Упс";
}
return 0;
}
Read the comments carefully!Are you really not catching up???Write some more code:everyone will be interested,How did you write such a complex problem in an unusual and simple way?…
f(x)=((sqrt(1.7*x+sin(x)^1/3 if 0<x<=2;
cos(pi*x)+tgx if 2<x<=6 how to solve a problem using C++, Help