Skip to content

Commit e360eee

Browse files
committed
some help
1 parent 5411421 commit e360eee

File tree

2 files changed

+88
-1
lines changed

2 files changed

+88
-1
lines changed

lab4.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,6 @@ int main(){
169169
std::cout<<std::endl<<"Запускаємо тести"<<std::endl;
170170
test();
171171

172-
delete arr;//вивільнення пам'яті
172+
delete[] arr;//вивільнення пам'яті
173173
return 0;
174174
}

lab5var14.cpp

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// ConsoleApplication2.cpp : This file contains the 'main' function. Program execution begins and ends there.
2+
//
3+
4+
#include <iostream>
5+
#include <windows.h>
6+
#include <iomanip>
7+
using namespace std;
8+
9+
int main()
10+
{
11+
SetConsoleOutputCP(CP_UTF8);
12+
int a;
13+
int b;
14+
int c;
15+
int sum = 0;
16+
const int ROW = 9;
17+
const int COL = 9;
18+
int Arr[ROW][COL];
19+
cout << "Введіть число a" << endl;
20+
cin >> a;
21+
cout << "Введіть число b" << endl;
22+
cin >> b;
23+
24+
25+
for (int i = 0; i < ROW; i++) {
26+
for (int j = 0; j < COL; j++) {
27+
Arr[i][j] = a + rand() % (b - a + 1);
28+
cout << setw(5)<< Arr[i][j] << " ";
29+
}
30+
cout << endl;
31+
}
32+
//
33+
/*
34+
1 2 3 4
35+
5 6 7 8.
36+
9 8 7 6.
37+
1 6 4 6.
38+
39+
*/
40+
for(int n=0; n<ROW; n++){
41+
int sum = 0;
42+
for(int j=COL-1; j>(ROW-n-1); j--){
43+
sum += Arr[j][n];
44+
}
45+
46+
Arr[ROW-1-n][n] = sum;
47+
}
48+
cout << endl << "друга хрень:" << endl;
49+
50+
for (int i = 0; i < ROW; i++) {
51+
for (int j = 0; j < COL; j++) {
52+
cout << setw(5) << Arr[i][j] << " ";
53+
}
54+
cout << endl;
55+
}
56+
57+
cout<<"Третя хрень:"<<endl;
58+
for(int n=0; n<ROW; n++){
59+
if(n%2==1){
60+
cout<<setw(5)<<0<<sum;
61+
continue;
62+
}
63+
64+
int sum = 0;
65+
for(int j=COL-1; j>=0; j--){
66+
sum += Arr[j][n];
67+
}
68+
69+
cout<<setw(5)<<sum;
70+
}
71+
72+
73+
cout << endl << "кінець" << endl;
74+
system("pause");
75+
return 0;
76+
}
77+
78+
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
79+
// Debug program: F5 or Debug > Start Debugging menu
80+
81+
// Tips for Getting Started:
82+
// 1. Use the Solution Explorer window to add/manage files
83+
// 2. Use the Team Explorer window to connect to source control
84+
// 3. Use the Output window to see build output and other messages
85+
// 4. Use the Error List window to view errors
86+
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
87+
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file

0 commit comments

Comments
 (0)