Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1
- #include <bits/stdc++.h>
- 2
- using namespace std;
- 3
- //int c[8][8];
- 4
- int *p,*r;
- 5
- int main ()
- 6
- {
- 7
- /*int n,m,i,j;
- 8
- cin>>n>>m;
- 9
- int v[n+1][m+1];
- 10
- for(i=1;i<=n;i++)
- 11
- {
- 12
- for(j=1;j<=m;j++)
- 13
- {
- 14
- v[i][j]=i*10+j;
- 15
- }
- 16
- }
- 17
- p=v[4];
- 18
- r=c[4];
- 19
- memcpy(r,p,sizeof(v)+m);
- 20
- for(i=1;i<=m;i++)
- 21
- {
- 22
- cout<<c[4][i]<<' ';
- 23
- }*/
- 24
- ifstream fin ("damage.in");
- 25
- ofstream fout ("damage.out");
- 26
- int n,m,i,j,g,cz=1;
- 27
- fin>>n>>m;
- 28
- g=1; //coloana dupa care sortam
- 29
- int v[n+1][m+1];
- 30
- int c[m+1];
- 31
- for(i=1;i<=n;i++)
- 32
- {
- 33
- for(j=1;j<=m;j++)
- 34
- {
- 35
- fin>>v[i][j];
- 36
- }
- 37
- }
- 38
- while(cz)
- 39
- {
- 40
- cz=0;
- 41
- for(i=1;i<n;i++)
- 42
- {
- 43
- if(v[i][g]>v[i+1][g])
- 44
- {
- 45
- p=v[i];
- 46
- r=v[i+1];
- 47
- memcpy(c,p,sizeof(v[i])+m);
- 48
- memcpy(p,r,sizeof(v[i])+m);
- 49
- memcpy(r,c,sizeof(v[i])+m);
- 50
- cz=1;
- 51
- }
- 52
- }
- 53
- }
- 54
- for(i=1;i<=n;i++)
- 55
- {
- 56
- for(j=1;j<=m;j++)
- 57
- {
- 58
- fout<<v[i][j]<<' ';
- 59
- }
- 60
- fout<<endl;
- 61
- }
- 62
- }
- 63
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement