[ create a new paste ] login | about

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

C, pasted on Oct 21:
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<Windows.h>
#define MAX 100


// Hàm tô màu
void textcolor(int x)
{
	HANDLE mau;
	mau = GetStdHandle
		(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(mau, x);
}
void nhap (int a[], int &n)
{
	do
	{
		printf("\nNhap so phan tu: ");
		scanf("%d", &n);
		if(n <= 0 || n > MAX)
		{
			printf("\nSo phan tu khong hop le. Xin kiem tra lai !");
		}
	}while(n <= 0 || n > MAX);
	for(int i = 0; i < n; i++)
	{
		printf("\nNhap a[%d]: ", i);
		scanf("%d", &a[i]);
	}
}

void XuatChanVangLeTrang(int a[], int n)
{
	for(int i = 0; i < n; i++)
	{
		if(a[i] % 2 == 0)
		{
			textcolor(14);
			printf("%4d", a[i]);
		}
		else
		{
			textcolor(7);
			printf("%4d", a[i]);
		}
	}
}


int main()
{
	int n, k;
	int a[MAX];

	nhap(a, n);
	XuatChanVangLeTrang(a, n);


	getch();
	return 0;
}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
Line 17: error: conio.h: No such file or directory
Line 19: error: Windows.h: No such file or directory
In function 'textcolor':
Line 11: error: 'HANDLE' undeclared (first use in this function)
Line 11: error: (Each undeclared identifier is reported only once
Line 11: error: for each function it appears in.)
Line 11: error: expected ';' before 'mau'
Line 12: error: 'mau' undeclared (first use in this function)
Line 13: error: 'STD_OUTPUT_HANDLE' undeclared (first use in this function)
t.c: At top level:
Line 16: error: expected ';', ',' or ')' before '&' token
In function 'XuatChanVangLeTrang':
Line 36: error: 'for' loop initial declaration used outside C99 mode


Create a new paste based on this one


Comments: