Advertisement
catalyn

problema matrice 15.09.2015

Sep 15th, 2015
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. /* Se citeste o matrice patratica de ordinul n din fisier. Afisati suma numerele pare de sub diagonala secundara, precum si
  2. numarul lor.
  3. */
  4.  
  5. #include <iostream>
  6. #include <fstream>
  7.  
  8. using namespace std;
  9.  
  10. ifstream f("date.in");
  11.  
  12. int main()
  13. {
  14. int n,a[100][100],i,j,s=0,c=0;
  15. f>>n;
  16. for (i=1;i<=n;i++)
  17. for (j=1;j<=n;j++)
  18. f>>a[i][j];
  19. for (i=2;i<=n;i++)
  20. for (j=n+2-i;j<=n;j++)
  21. if (a[i][j]%2==0)
  22. {
  23. s=s+a[i][j];
  24. c++;
  25. }
  26. cout<<s<<" "<<c;
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement