OK i got your point. But i tried this way. i gives me a segmentation fault...whats the problem here can any1 help me??
I will be greatful.

Code:
#include <iostream>
#include <vector>
#include <time.h>
using namespace std;

int main (void)
{
	time_t tm;
	time(&tm);
	srand(tm);
	vector <vector<int> > v (5,vector<int>(5));
	vector<int>::iterator it;
	int rnd;
	for (int i=0;i<5;i++)
	{
		for ( int j=0;j<5;j++)
		{
		rnd = rand() % 100;
		v[i][j]= rnd;
		//cout<<v[i][j]<<" ";
		}
	}
	int k;
	for (int i=0;i<4;i++)
	{
		while (abs( ( (v[i].back() )-(v[i+1].front() ) ) < 30))
		{
				k = v[i+1].front();
				v[i+1].erase(v[i+1].begin() );
				v[i].push_back(k);	
		}

	}
	
	for (int i=0;i<v.size();i++)
	{
		//cout<<v[i].size()<<" ";
		for(int j=0;j<v[i].size();j++)
		{
			cout<<v[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
return 0;
}