Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <clocale>
- #include <math.h>
- #include <iomanip>
- using namespace std;
- const int n = 6;
- int f(int x[n][n]){
- int pol = 0, otr = 0;
- for (int i = 0; i < n; i++){
- cout << '\n';
- for (int j = n-i-1; j < n; j++){
- if (x[i][j] < 0){
- otr++;
- cout << "отр: " << x[i][j] << '\n';
- }
- if (x[i][j] > 0){
- pol++;
- cout << "пол: " << x[i][j] << '\n';
- }
- }
- }
- cout << '\n' << "Кол-во отрицательных = " << otr;
- cout << '\n' << "Кол-во положительных = " << pol;
- cout << '\n';
- return 0;
- }
- int main(){
- int a[n][n];
- for (int i = 0; i < n; i++){
- cout << '\n';
- for (int j = 0; j < n; j++){
- a[i][j] = rand()%100 - 50;
- cout << setw(4) << a[i][j];
- }
- }
- cout << '\n' << f(a);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement