All pastes #908258 Raw Edit

Unnamed

public text v1 · immutable
·published 2008-02-18 07:33 UTC
rendered paste body
#include <iostream>
#include <fstream>

using namespace std;
int n,m;
int a[255];
int c=2;
void Inserare(int p)
{
	for(int i=0;i<c;i++)
	{
		if(p>=a[i])
		{
			for(int j=c+1;j>i;j--)
			{
				a[j] = a[j-1];
			}
			a[i] = p;
			c++;
			return;
		}
		
	}
	
}


void Read()
{
	ifstream fin("file.in");
	fin >> n >>m>>a[0]>>a[1];
	for(int i=2;i<n;i++)
	{
		int t;
		fin >> t;
		Inserare(t);
	}
	for(int i=0;i<m-2;i++)
	{
		int t;
		fin >> t;
		Inserare(t);
		for(int j=1;j<n-1;j++)
		{
			fin >> t;
		}

		fin >> t;
		Inserare(t);
	}
	for(int i=0;i<n;i++)
	{
		int t;
		fin >> t;
		Inserare(t);
	}
}

void main()
{
	Read();
	for(int i=0;i<c;i++)
	{
		cout << a[i] << " ";
	}
}