Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. 1
  2.  
  3. #include <bits/stdc++.h>
  4. 2
  5.  
  6. using namespace std;
  7. 3
  8.  
  9. //int c[8][8];
  10. 4
  11.  
  12. int *p,*r;
  13. 5
  14.  
  15. int main ()
  16. 6
  17.  
  18. {
  19. 7
  20.  
  21. /*int n,m,i,j;
  22. 8
  23.  
  24. cin>>n>>m;
  25. 9
  26.  
  27. int v[n+1][m+1];
  28. 10
  29.  
  30. for(i=1;i<=n;i++)
  31. 11
  32.  
  33. {
  34. 12
  35.  
  36. for(j=1;j<=m;j++)
  37. 13
  38.  
  39. {
  40. 14
  41.  
  42. v[i][j]=i*10+j;
  43. 15
  44.  
  45. }
  46. 16
  47.  
  48. }
  49. 17
  50.  
  51. p=v[4];
  52. 18
  53.  
  54. r=c[4];
  55. 19
  56.  
  57. memcpy(r,p,sizeof(v)+m);
  58. 20
  59.  
  60. for(i=1;i<=m;i++)
  61. 21
  62.  
  63. {
  64. 22
  65.  
  66. cout<<c[4][i]<<' ';
  67. 23
  68.  
  69. }*/
  70. 24
  71.  
  72. ifstream fin ("damage.in");
  73. 25
  74.  
  75. ofstream fout ("damage.out");
  76. 26
  77.  
  78. int n,m,i,j,g,cz=1;
  79. 27
  80.  
  81. fin>>n>>m;
  82. 28
  83.  
  84. g=1; //coloana dupa care sortam
  85. 29
  86.  
  87. int v[n+1][m+1];
  88. 30
  89.  
  90. int c[m+1];
  91. 31
  92.  
  93. for(i=1;i<=n;i++)
  94. 32
  95.  
  96. {
  97. 33
  98.  
  99. for(j=1;j<=m;j++)
  100. 34
  101.  
  102. {
  103. 35
  104.  
  105. fin>>v[i][j];
  106. 36
  107.  
  108. }
  109. 37
  110.  
  111. }
  112. 38
  113.  
  114. while(cz)
  115. 39
  116.  
  117. {
  118. 40
  119.  
  120. cz=0;
  121. 41
  122.  
  123. for(i=1;i<n;i++)
  124. 42
  125.  
  126. {
  127. 43
  128.  
  129. if(v[i][g]>v[i+1][g])
  130. 44
  131.  
  132. {
  133. 45
  134.  
  135. p=v[i];
  136. 46
  137.  
  138. r=v[i+1];
  139. 47
  140.  
  141. memcpy(c,p,sizeof(v[i])+m);
  142. 48
  143.  
  144. memcpy(p,r,sizeof(v[i])+m);
  145. 49
  146.  
  147. memcpy(r,c,sizeof(v[i])+m);
  148. 50
  149.  
  150. cz=1;
  151. 51
  152.  
  153. }
  154. 52
  155.  
  156. }
  157. 53
  158.  
  159. }
  160. 54
  161.  
  162. for(i=1;i<=n;i++)
  163. 55
  164.  
  165. {
  166. 56
  167.  
  168. for(j=1;j<=m;j++)
  169. 57
  170.  
  171. {
  172. 58
  173.  
  174. fout<<v[i][j]<<' ';
  175. 59
  176.  
  177. }
  178. 60
  179.  
  180. fout<<endl;
  181. 61
  182.  
  183. }
  184. 62
  185.  
  186. }
  187. 63
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement