1. Common task: Given the four-digit number (for example 5678), display the numbers in reverse order of which is the number of member. That is, we should see on the screen 8765. Tip: to take from among the individual numbers, should be applied to the modulo 10.
Show code
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
usingnamespacestd;
intmain()
{
setlocale(LC_ALL,"rus");
intmainNumber=5678;
cout<<"Дано целое число: "<<mainNumber<<endl;
cout<<"Число наизнанку: ";
// остаток от деления четырехзначного числа 5678 на 10
cout<<mainNumber%10;// 5678 % 10 = 8
// далее делим mainNumber на 10 и записываем в переменную
// так как тип переменной int, дробная часть отбросится
// и mainNumber будет равен 567 (а не 567,8)
mainNumber/=10;
// показываем остаток от деления 567 на 10 на экран
cout<<mainNumber%10;
mainNumber/=10;
cout<<mainNumber%10;
mainNumber/=10;
cout<<mainNumber%10;
mainNumber/=10;
cout<<endl<<endl;
return0;
}
Result:
2. The site of almost any commercial bank, you can find the so-called Deposit calculator, which allows people to, not wishing to go into the formula for calculating interest rates, to know how much they will receive. To do this, they just fill in certain fields, press the button and see the result. This is a simple program, which has already been able to write each one of you. So, a task: The user enters the amount of the deposit and the number of months of keeping money in the bank. It is necessary to calculate and show the screen profit from the deposit in a month, for the entire term of the deposit, and the total amount payable at the end of the period. Currency let it be – U.S. dollar. Interest rate – 5% APR. The formula for calculating percent per month– SumDeposit * (interest rate / 100) / daysperyear * dayspermonths.
Ахахахааххаахах гениально. Немного доработал ваш код.
#include using namespace std;
int main () { int a=5; int b=6; int c=7; int d=8; cout << "Данно целое число: " < <a << b << c << d << endl; cout << "Число наизнанку: " << d << c << b << a << endl; }
#include
using namespace std;
int main(){
unsigned long int a,c=0;
cin>>a;
while (a!=0){
c*=10;
c=c+a%10;
a/=10;
}
cout<<c;
return 0;
}
Проверка на палиндром .
Можно не писать Unsigned long.
#include
using namespace std;
int main()
{
setlocale(LC_CTYPE, “Russian”);
float depozit = 0, srok = 0;
cout <> depozit;
cout <> srok;
cout << "прибыль в месяц:" << depozit * 0.05 / 365 * 30 << "$" << endl;
cout << "прибыль за весь срок:" << depozit * 0.05 / 365 * 30 * srok << "$" << endl;
cout << "итоговая выплата:" << depozit * 0.05 / 365 * 30 * srok + depozit << "$" << endl;
return 0;
}
Пойду против правил. Зачем писать большой код, если можно так:
#include
using namespace std;
int main()
{
char a, b, c, d;
cin >> a >> b >> c >> d;
cout << d << c << b << a;
}
Ахахахааххаахах гениально.
Немного доработал ваш код.
#include
using namespace std;
int main ()
{
int a=5;
int b=6;
int c=7;
int d=8;
cout << "Данно целое число: " < <a << b << c << d << endl;
cout << "Число наизнанку: " << d << c << b << a << endl;
}
#include
using namespace std;
void magazin() { //zadacha iz purecodecpp.com/archives/433
int m = 0, sh = 0, co = 0;
int sum;
int mRub = 79, shRub = 124, coRub = 735;
int sumRub;
int menunum;
system(“color 2″);
for (menunum = 0; menunum < 4;) {
cout << "\t\t~ DOBRO POJALOVAT' V MAGAZIN CITY 17 ~\n\n";
cout <> DOBAVIT’ V KORZINU: \n====================================================================\n”;
cout <> 1. MOLOKO\t\t\t79 rub.\t\t—-\t” << m << "\tsht.\n";
cout <> 2. SHOKOLADKA\t\t124 rub.\t—-\t” << sh << "\tsht.\n";
cout <> 3. DEVYATOK YAITS\t\t735 rub.\t—-\t” << co << "\tsht.\n";
cout <> 4. KUPIT’ S DOSTAVKOY\t3500 rub.\t—-\t-\t—-\n>>\n>> “;
cin >> menunum;
switch (menunum) {
case 1:
m++;
break;
case 2:
sh++;
break;
case 3:
co++;
break;
case 4:
sum = m + sh + co;
mRub *= m;
shRub *= sh;
coRub *= co;
sumRub = mRub + shRub + coRub + 3500;
cout << "\n====================================================================\n";
cout <> ITOGO:\t\t\t” << sumRub << "* rub.\t—-\t" << sum <> *s uchetom dostavki :)\n\n”;
system(“pause”);
default:
menunum = 0;
}
if (menunum != 4) {
menunum = 0;
}
system(“cls”);
}
}
void bank() { //zadacha iz purecodecpp.com/archives/433
int depo = 0, mes = 0, prib = 0;
int procmes = 0, procgod = 0;
int menunum;
system(“color 2″);
for (menunum = 0; menunum < 3;) {
cout << "\t\t~ DOBRO POJALOVAT' V BANK CITY 17 ~\n\n";
cout <> DEPOZITNIY KALKULATOR: \n============SPESHITE! PROTSENTNAYA STAVKA 0.2% GODOVIH!!!========\n>>\n”;
cout <> 1. SUMMA DEPOZITA\t\t\t” << depo << "\trub.\n";
cout <> 2. SKOL’KO MESYATSEV HRANIT’\t\t” << my << "\tmesyatsev\n";
cout <> 3. POSCHITAT’ PRIBIL’…\n>>\n>> “;
cin >> menunum;
switch (menunum) {
case 1:
system(“cls”);
cout << "\t\t~ DOBRO POJALOVAT' V BANK CITY 17 ~\n\n";
cout <> DEPOZITNIY KALKULATOR: \n============SPESHITE! PROTSENTNAYA STAVKA 0.2% GODOVIH!!!========\n>>\n”;
cout <> depo;
break;
case 2:
system(“cls”);
cout << "\t\t~ DOBRO POJALOVAT' V BANK CITY 17 ~\n\n";
cout <> DEPOZITNIY KALKULATOR: \n============SPESHITE! PROTSENTNAYA STAVKA 0.2% GODOVIH!!!========\n>>\n”;
cout <> my;
break;
case 3:
procmes = depo * (0.2 / 100) / 365 * 30;
procgod = procmes * 12;
cout << "\n====================================================================\n";
cout <> PRIBIL’ SOSTAVIT:\n>>\n”;
cout <> V MESYATS:\t\t\t” << procmes << "\trub.\n";
cout <> V GOD:\t\t\t” << procgod << "\trub.\n\n";
system("PAUSE");
default:
menunum = 0;
}
if (menunum != 3) {
menunum = 0;
}
system("cls");
}
}
int main()
{
int menuitem = 0;
system("color 2");
cout << "\t\t~ DOBRO POJALOVAT' V 'My HeLLo WORLD!' ~\n\n";
cout <> VIBRAT’ PUNKT: \n====================================================================\n”;
cout <> 1. MAGAZIN\n”;
cout <> 2. BANK\n”;
cout <> 99. VIHOD\n>>\n>> “;
cin >> menuitem;
switch (menuitem) {
case 1:
system(“cls”);
magazin();
break;
case 2:
system(“cls”);
bank();
break;
case 99:
system(“exit”);
default:
menuitem = 0;
}
return 0;
}
#include
using namespace std;
int main()
{
int num;
cin >> on one;
for (on one; on one != 0; num /= 10)
cout << on one % 10;
return 0;
}
по формуле расчета процентов консультировался с экономистом, тут программа считает сложный процент.
#include
#include
using namespace std;
int main() {
double b, d, x, t, c;
int a;
cout << "enter summ depozit " <> x;
cout << "enter kol-vo mounse " <> a;
cout << "enter % stavku " <> c;
c /= 100;
t = 1 + c / 12;
b = pow(t, a) ;
b *= x;
d = (b – x) / a;
cout << "summa vklada itog : " << b << endl;
cout << "zarabotok v mes : " << d << endl;
return 0;
}
short a=0;
cin >> a;
cout << a % 10;
cout << (a / 10) % 10;
cout << (a / 100) % 10;
cout << (a / 1000) % 10;