Advertisement
Guest User

Untitled

a guest
Jul 5th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. //#include "stdafx.h" Po co to?
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. const int WMAX = 50, KMAX = 20;
  6. int f1(float wektor[], int ile_el, float *suma) //ta funkcja rzekomo ma zwracac ile, ile to int, więc nie VOID (funkcja void nic nie wzraca) tylko INT!!!
  7. {
  8. *suma = 0;
  9. for (int i = 0; i < ile_el; i++)
  10. if (wektor[i] >= 3.51)
  11. *suma += wektor[i];
  12. int ile;
  13. ile = 0;
  14. for (int i = 0; i < ile_el; i++)
  15. if (wektor[i]> 0)
  16. ile++;
  17. return ile;
  18. }
  19.  
  20. int main() //nie wiem co w srodku bylo, mi to jakos nigdy potrzebne nie bylo
  21. {
  22. float A[WMAX][KMAX];
  23. int m, n;
  24. cout << "Podaj liczbe wierszy: ";
  25. cin >> m;
  26. cout << "Podaj liczbe kolumn: ";
  27. cin >> n;
  28. wczytaj_macierz(A, m, n); //Nie wiem co gdzie i jak
  29. float suma_el;
  30. int liczba_el; //tutaj chyba ma byc int, bo liczba elementow to liczba calkowita
  31. f1(A[0], liczba_el, &suma_el); //pomyliles kolejnosc, zwracaj na to uwage, chciales przeslac 4 argumenty do funkcji ktora przyjmuje 3 - to blad!
  32. cout << "Suma elementow o wartosci conajmniej 3.51 wynosi: " << suma_el << endl;
  33. cout << "Liczba elementów dodatnich wynosi: " << liczba_el << endl;
  34.  
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement