-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfoo.cpp
83 lines (77 loc) · 1.83 KB
/
foo.cpp
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <iostream>
#include <clocale>
using namespace std;
void ARR(){
int array[] = {1,0,0,1,0,1,0,1};
int b;
b = sizeof(array)/sizeof(array[0]);
for (int i = 0; i < b; i++){
if (array[i] == !1){
array[i] = 1;
} else if (array[i] == !0){
array[i] = 0;
}
cout << array[i] << ' ';
}
cout << endl;
}
void ARR2(){
int array[8] = {};
int b;
int c = 1;
b = sizeof(array)/sizeof(array[8]);
for (int i = 0; i < b; i++){
array[i] = c;
c = c + 2;
cout << array[i] << ' ';
}
cout << endl;
}
bool ARR3(int array[], const int size){
for (int i = 0; i < size; i++){
int sum = 0;
for (int j = 0; j < i; j++){
sum = sum + array[j];
}
for (int j = i; j < size; j++){
sum = sum - array[j];
}
if (sum == 0){
return true;
}
}
return false;
}
void ARR4(int array[], const int SIZE){
string sim;
int chislo_it;
cout << "enter the number to shift ";
cin >> chislo_it;
cout << endl;
cout << "enter side (<< or >>) ";
cin >> sim;
if (sim == "<<"){
for (int i = 0; i < chislo_it; i++){
int tmp = array[0];
for (int i = 0; i < SIZE - 1; i++){
array[i] = array[i + 1];
}
array[SIZE - 1] = tmp;
}
for (int i = 0; i < SIZE; i++){
cout << array[i];
}
}
else if (sim == ">>"){
for (int i = 0; i < chislo_it; i++){
int tmp = array[SIZE - 1];
for (int i = SIZE - 1; i > 0; i--){
array[i] = array[i - 1];
}
array[0] = tmp;
}
for (int i = 0; i < SIZE; i++){
cout << array[i];
}
}
}