Quick actions

cmd+k|ctrl+k

Navigation

Languages

lab7-1061

Snippet info

Language

Cpp

Visibility

public

Author

matho.camara

Created

2018-12-12T08:34:58Z

Updated

2018-12-12T08:52:26Z

#include <iostream>
#include <time.h>

using namespace std;

int main() {
    srand((unsigned) time(NULL));
    int k,s,n=15,m=5,table[n][m],temp;
    
    
    cout << "Input K ans S values: "<<endl;
    cin>>k>>s;
    
    //filling the table
     for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        table[i][j]=rand()%20;
    }
    
    //show the table's content
     for(int i=k-1;i<s-1;i++)
    {
        for(int j=0;j<m;j++)
        {
           cout<<" "<<table[i][j];
        }
        cout<<endl; 
    }
    
    //reordering the rows
    if((k<n && s<n) && k<s)
    {
        for(int i=k-1;i<s-1;i++)
        {
            for(int j=0;j<m;j++)
            {
                 temp=table[i][j];
                 table[i][j]=table[i+1][j];
                 table[i+1][j]=temp;
            }
        }
    }
    
     //show the table's content
     cout<<"Reodered :"<<endl;
    for(int i=k-2;i<s-1;i++)
    {
        for(int j=0;j<m;j++)
        {
           cout<<" "<<table[i][j];
        }
        cout<<endl;
    }
    return 0;
}
INFO