Created
July 5, 2017 12:29
-
-
Save kabachuha/d63f9f14070d3bab5210e5778a0367e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
const int size = 10; | |
float a[size]; | |
for(int i = 0; i < size; i++) | |
{ | |
cin >> a[i]; | |
} | |
for(int i = 0; i < size; i++) | |
{ | |
if(int(a[i]) % 4 == 0) | |
{ | |
if(i < 3) | |
continue; | |
a[i] = (a[i-1]+a[i-2]+a[i-3])/3; | |
} | |
} | |
for(int i = 0; i < size; i++) | |
{ | |
cout << a[i] << endl; | |
} | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
const int size = 8; | |
int a[size], b[size], c[size], d[3*size]; | |
for(int i = 0; i < size*3; i++) | |
{ | |
if(i < size) | |
{ | |
cin >> a[i]; | |
} | |
else if(i < size*2) | |
{ | |
cin >> b[i - size]; | |
} | |
else | |
{ | |
cin >> c[i- (size * 2)]; | |
} | |
} | |
for(int i = 0; i < size; i++) | |
{ | |
cout << a[i] << " "; | |
cout << b[i] << " "; | |
cout << c[i] << " "; | |
} | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
const int size = 5; | |
int a[size], b[size], k, ff1 = 0, ff2 = 0; | |
for(int i = 0; i < size*2; i++) | |
{ | |
cin >> k; | |
if(k >= 0) | |
{ | |
a[ff1] = k; | |
ff1++; | |
} | |
else | |
{ | |
b[ff2] = k; | |
ff2++; | |
} | |
} | |
for(int i = 0; i < size; i++) | |
{ | |
cout << a[i] << " "; | |
cout << b[i] << " "; | |
} | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
const int size = 10; | |
int x, index = -1, product = 1, sum = 0; | |
for(int i = 0; i < size; i++) | |
{ | |
cin >> x; | |
if(x == 0 && index == -1) | |
{ | |
index = x; | |
continue; | |
} | |
if(index == -1) | |
product *= x; | |
if(i > index && index != -1) | |
sum += x; | |
} | |
cout << "Product before 0 = " << product << endl; | |
cout << "Sum after 0 = " << sum << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment