[ create a new paste ] login | about

Link: http://codepad.org/kw4hGnrt    [ raw code | output | fork ]

C, pasted on Jan 6:
#include <iostream>
using namespace std;

void InterchangeSort(int* a, int x, int y)
{
	for(int i = x; i < y - 1; i++)
	{
		for(int j = i + 1; j < y; j++)
		{
			if(a[i] > a[j])
				swap(a[i], a[j]);
		}
	}
}

void XuatMang(int* a, int n)
{
	for(int i = 0; i < n; i++)
		cout << i[a] << "\t";
}

void LietKeHoanVi(int* a, int n)
{
	XuatMang(a, n);
	cout << endl;
	while(true)
	{
		bool check = false;
		for(int i = n - 1; i > 0; i--)
		{
			if(a[i - 1]  < a[i])
			{
				InterchangeSort(a, i, n );
				for(int j = i; j < n; j++)
				{
					if(a[j] > a[i - 1])
					{
						swap(a[j], a[i - 1]);
						break;
					}
				}
				check = true;
				break;
			}
		}

		if(check == false)
			break;
		XuatMang(a, n);
		cout << endl;
	}
}
int main()
{
	int n = 5;
	int* a = new int [n];
	for(int i = 0; i < n; i++)
	{
		a[i] = i + 1;
	}
	LietKeHoanVi(a, n);
	system("pause");
	delete []a;
}


Output:
Line 19: error: iostream: No such file or directory
Line 2: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'namespace'
In function 'InterchangeSort':
Line 6: error: 'for' loop initial declaration used outside C99 mode
Line 8: error: 'for' loop initial declaration used outside C99 mode
In function 'XuatMang':
Line 18: error: 'for' loop initial declaration used outside C99 mode
Line 19: error: 'cout' undeclared (first use in this function)
Line 19: error: (Each undeclared identifier is reported only once
Line 19: error: for each function it appears in.)
In function 'LietKeHoanVi':
Line 25: error: 'cout' undeclared (first use in this function)
Line 25: error: 'endl' undeclared (first use in this function)
Line 26: error: 'true' undeclared (first use in this function)
Line 28: error: 'bool' undeclared (first use in this function)
Line 28: error: expected ';' before 'check'
Line 29: error: 'for' loop initial declaration used outside C99 mode
Line 34: error: 'for' loop initial declaration used outside C99 mode
Line 42: error: 'check' undeclared (first use in this function)
Line 47: error: 'false' undeclared (first use in this function)
In function 'main':
Line 56: error: 'new' undeclared (first use in this function)
Line 56: error: expected ',' or ';' before 'int'
Line 57: error: 'for' loop initial declaration used outside C99 mode
Line 63: error: 'delete' undeclared (first use in this function)
Line 63: error: expected expression before ']' token


Create a new paste based on this one


Comments: