Advertisement
catalyn

problema 2 -29.10.2014 miercuri

Oct 29th, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. //scrieti un program care sterge dintr-o matrice cu m linii n coloane liniile cu nr par si afisaza matricea ramasa.
  2. #include <iostream>
  3. #include <fstream>
  4. using namespace std;
  5. ifstream f("date.in");
  6. ofstream g("date.out");
  7. int a[100][100],m,n;
  8. void citire(int a[100][100],int &nr1,int &nr2)
  9. {
  10. int i,j;
  11. f>>nr1>>nr2;
  12. for(i=1;i<=nr1;i++)
  13. for(j=1;j<=nr2;j++)
  14. f>>a[i][j];
  15. }
  16. void stergere (int l)
  17. {
  18. int i,j;
  19. if(l==m)
  20. n--;
  21. else
  22. for(i=l;i<m;i++)
  23. for(j=1;j<=n;j++)
  24. a[i][j]=a[i+1][j];
  25. }
  26. void rezolva()
  27. {int i,j,mm=m;
  28. for(i=2;i<=mm/2+1;i++)
  29. stergere(i);
  30. m--;}
  31. int main ()
  32. {
  33. int i,j;
  34. rezolva();
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement