Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. int a[20][20],n;
  5. void citire()
  6. {
  7. int i,j;
  8. fstream f("atestat.in.in",ios::in);
  9. f>>n;
  10. for(i=1;i<=n;i++)
  11. for(j=1;j<=n;j++)
  12. f>>a[i][j];
  13. f.close();
  14. }
  15. void afisare_a()
  16. {
  17. int i,j;
  18. for(i=1;i<=n;i++)
  19. {
  20. for(j=1;j<=n;j++)
  21. cout<<a[i][j]<<" ";
  22. cout<<endl;
  23. }
  24.  
  25. }
  26. void afisare_b()
  27. {
  28. int i,j,k,gasit=0;
  29. cout<<"valoare cautata este";
  30. cin>>k;
  31. for(i=1;i<=n&&gasit==0;i++)
  32. for(j=1;j<=n&&gasit==0;j++)
  33. if(a[i][j]==k)
  34. gasit=1;
  35. if(gasit==1)
  36. cout<<"valoreeeeeeeeeee"<<k<<"se afla in matrice";
  37. else
  38. cout<<"VALOAREEEEEEEEEEEEE"<<k<<"nu se afla in matrie";
  39.  
  40. }
  41. void afisare_c()
  42. {
  43. int i,j;
  44. fstream g("atestat.in.out",ios::out);
  45. for(j=1;j<=n;j++)
  46. a[n][j]=0;
  47. for(i=1;i<=n;i++)
  48. {
  49. for(j=1;j<=n;j++)
  50. g<<a[i][j]<<" ";
  51. g<<endl;
  52. }
  53. g.close();
  54. }
  55. int main()
  56. {
  57. citire();
  58. afisare_a();
  59. afisare_b();
  60. afisare_c();
  61. return 0;
  62. }
  63. 13
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement