daily pastebin goal
5%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <Windows.h>
  4. using namespace std;
  5. const int wmax = 30, kmax = 30;
  6.  
  7. int f1(float wektor[wmax], int ilw)
  8. {
  9.     int i;
  10.     int wynik=0;
  11.         for (i = 0;i<ilw;i ++)
  12.         {
  13.             if(i%2!=0)
  14.             if (wektor[i] > 0)
  15.                 wynik += 1;
  16.         }
  17.     return wynik;
  18. }
  19.  
  20. void f2(float macierz[wmax][kmax], int ilw, int ilk, float *dodaj, int& liczbaw)
  21. {
  22.     liczbaw = 0;
  23.     int i, j, x = 0;
  24.     for (i = 0;i < ilw;i++)
  25.     {
  26.         for (j = 0;j < ilk;j++)
  27.         {
  28.             if (macierz[i][j] > -3.2 && macierz[i][j] < 11)
  29.             {
  30.                 *dodaj += macierz[i][j] + macierz[i][j];
  31.             }
  32.  
  33.             if (macierz[i][j] > 0)
  34.             {
  35.                 x += 1;
  36.             }
  37.         }
  38.         if (x == j)
  39.         {
  40.             liczbaw += 1;
  41.         }
  42.     }
  43. }
  44.  
  45. int main()
  46. {
  47.     SetConsoleCP(1250);
  48.     SetConsoleOutputCP(1250);
  49.     float A[wmax][kmax];
  50.     int m, n, i, j, wynik = 0;
  51.     float suma = 0;
  52.     int licz = 0;
  53.     float *a = &suma;
  54.     cout << "Podaj liczbę wierszy" << endl;
  55.     cin >> m;
  56.     cout << "Podaj liczbę kolumn" << endl;
  57.     cin >> n;
  58.     for (i = 0;i < m;i++)
  59.     {
  60.         for (j = 0;j < n;j++)
  61.         {
  62.             cout << "Podaj wartość pola " << i + 1 << ", " << j + 1 << " macierzy A:" << endl;
  63.             cin >> A[i][j];
  64.         }
  65.     }
  66.     wynik = f1(A[0], n);
  67.     cout << "wektor " << wynik << endl;
  68.     f2(A, m, n, a, licz);
  69.     cout << " suma i liczba wierszy " << suma << " , " << licz << endl;
  70.     system("pause");
  71.     return 0;
  72. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top