Home
О нас
Products
Services
Регистрация
Войти
Поиск
nadiyaru
@nadiyaru
August 2022
1
10
Report
Помогите пожалуйста Очень нужно. Задачка на С++
Please enter comments
Please enter your name.
Please enter the correct email address.
Agree to
terms of service
You must agree before submitting.
Send
Answers & Comments
petyaGavrikov
Verified answer
#include <iostream>
using namespace std;
int main() {
int n, y;
cout << "n = ";
cin >> n;
cout << "y = ";
cin >> y;
int a[11][6];
int n3, n5;
cout << "---------------------------------------\n";
a[0][0] = n;
for (int i=0; i<y; i++){
n = a[i][0];
n5 = n / 5;
n3 = 0;
while (n3*3+n5*5 != n) {
if ((n-n5*5) % 3 == 0)
n3 = (n-n5*5) / 3;
else n5 = n5-1;
}
a[i][1] = n3; a[i][2] = n5;
a[i][3] = a[i][1]*5+a[i][2]*9;
if ((i==0)||(i==1)) a[i][4] = 0;
else if (i==2) a[i][4] = a[0][0];
else a[i][4] = a[i-3][3];
a[i][5] = a[i][0]+a[i][3]-a[i][4];
a[i+1][0] = a[i][5];
}
for (int i=0; i<y; i++) {
cout << i+1 << " ";
for (int j=0; j<6; j++) {
cout.width(8);
cout << a[i][j] << " ";
}
cout << endl;
}
return 0;
}
Пример:
n = 9
y = 10
---------------------------------------
1 9 3 0 15 0 24
2 24 3 3 42 0 66
3 66 2 12 118 9 175
4 175 0 35 315 15 475
5 475 0 95 855 42 1288
6 1288 1 257 2318 118 3488
7 3488 1 697 6278 315 9451
8 9451 2 1889 17011 855 25607
9 25607 4 5119 46091 2318 69380
10 69380 0 13876 124884 6278 187986
2 votes
Thanks 1
More Questions From This User
See All
nadiyaru
August 2022 | 0 Ответы
s poschitat funkciyu u3h h2 esli h kratno 3 i funkciyu u 2h 10 esli h k
Answer
nadiyaru
August 2022 | 0 Ответы
pomogite pozhalujsta s zadachej po s
Answer
nadiyaru
August 2022 | 0 Ответы
pomogite pozhalujsta s 2 zadaniyami s
Answer
nadiyaru
July 2022 | 0 Ответы
pomogite s zadachej po javascript nachalnyj uroven
Answer
nadiyaru
July 2022 | 0 Ответы
3; } if (table[i][j] == 'O' || table[i][j] == 'X') return false; if (step) { tab...
Answer
nadiyaru
July 2022 | 0 Ответы
napisat programmu kotoraya 1 dano veshestvennoe chislo x poschitat funkciyu vo
Answer
nadiyaru
July 2022 | 0 Ответы
pomogite pozhalujstas v zadachah primenit operatory cikla zadanie 1 napisa
Answer
nadiyaru
July 2022 | 0 Ответы
pomogite pozhalujsta sdelat kalendar na god s vot primer na mesyac polzovat
Answer
nadiyaru
July 2022 | 0 Ответы
pomogite pozhalujsta s 1 najti vse prostye chisla iz intervala 1000 9999 u kot
Answer
nadiyaru
July 2022 | 0 Ответы
pomogite pozhalujsta 1 napisat programmu kotoraya nahodit v massive znacheniya p
Answer
рекомендуемые вопросы
rarrrrrrrr
August 2022 | 0 Ответы
o chem dolzhny pozabotitsya v pervuyu ochered vzroslye pri organizacionnom vyvoze n
danilarsentev
August 2022 | 0 Ответы
est dva stanka na kotoryh vypuskayut odinakovye zapchasti odin proizvodit a zapcha
myachina8
August 2022 | 0 Ответы
najti po grafiku otnoshenie v3v1 v otvetah napisano 9 no nuzhno reshenie
ydpmn7cn6w
August 2022 | 0 Ответы
Choose the correct preposition: 1.I am fond (out,of,from) literature. 2.where ar...
millermilena658
August 2022 | 0 Ответы
opredelite kak sozdavalas i kto sozdaval arabskoe gosudarstvo v kracii
MrZooM222
August 2022 | 0 Ответы
ch ajtmanov v rasskaze krasnoe yabloko ispolzuet metod rasskaz v rasskaze opi
timobila47
August 2022 | 0 Ответы
kakovo bylo naznachenie kazhdoj iz chastej vizantijskogo hrama pomogite pozhalujsta
ivanyyaremkiv
August 2022 | 0 Ответы
moment. 6....
pozhalujsta8b98a56c0152a07b8f4cbcd89aa2f01e 97513
sarvinozwakirjanova
August 2022 | 0 Ответы
pomogite pozhalusto pzha519d7eb8246a08ab0df06cc59e9dedb 6631
×
Report "Помогите пожалуйста Очень нужно. Задачка на С++..."
Your name
Email
Reason
-Select Reason-
Pornographic
Defamatory
Illegal/Unlawful
Spam
Other Terms Of Service Violation
File a copyright complaint
Description
Helpful Links
О нас
Политика конфиденциальности
Правила и условия
Copyright
Контакты
Helpful Social
Get monthly updates
Submit
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Verified answer
#include <iostream>using namespace std;
int main() {
int n, y;
cout << "n = ";
cin >> n;
cout << "y = ";
cin >> y;
int a[11][6];
int n3, n5;
cout << "---------------------------------------\n";
a[0][0] = n;
for (int i=0; i<y; i++){
n = a[i][0];
n5 = n / 5;
n3 = 0;
while (n3*3+n5*5 != n) {
if ((n-n5*5) % 3 == 0)
n3 = (n-n5*5) / 3;
else n5 = n5-1;
}
a[i][1] = n3; a[i][2] = n5;
a[i][3] = a[i][1]*5+a[i][2]*9;
if ((i==0)||(i==1)) a[i][4] = 0;
else if (i==2) a[i][4] = a[0][0];
else a[i][4] = a[i-3][3];
a[i][5] = a[i][0]+a[i][3]-a[i][4];
a[i+1][0] = a[i][5];
}
for (int i=0; i<y; i++) {
cout << i+1 << " ";
for (int j=0; j<6; j++) {
cout.width(8);
cout << a[i][j] << " ";
}
cout << endl;
}
return 0;
}
Пример:
n = 9
y = 10
---------------------------------------
1 9 3 0 15 0 24
2 24 3 3 42 0 66
3 66 2 12 118 9 175
4 175 0 35 315 15 475
5 475 0 95 855 42 1288
6 1288 1 257 2318 118 3488
7 3488 1 697 6278 315 9451
8 9451 2 1889 17011 855 25607
9 25607 4 5119 46091 2318 69380
10 69380 0 13876 124884 6278 187986