[ create a new paste ] login | about

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

C, pasted on Apr 24:
#include<stdio.h>
#include<conio.h>

bool deQuy(int n)
{
	if(n == 0)
		return true;  // toàn lẻ
	if((n % 10) % 2 == 0)
		return false; // sai do đã phát hiện ra có 1 chữ số chẵn
	return deQuy(n / 10); // bỏ đi 1 chữ số
}

bool ToanChuSoLe (int N)
{
	if (N < 10) return (N % 2 == true);
	int HangDonVi = N % 10;
	return (HangDonVi % 2 == true) && ToanChuSoLe(N/10);
}

bool khuDeQuy(int n)
{
	printf("\nSo %d gom toan cac chu so le hay khong ?\n", n);
	bool Check = true;
	while(n /= 10)
	{
		if((n % 10) % 2 == 0)
		{
			Check = false;
		    break;
		}
	}
	return Check;
}
int main()
{
	int n;
	printf("\nNhap n: "); scanf("%d", &n);

	bool check1= deQuy(n);
	if(check1)
		printf("\nToan chu so le!");
	else
		printf("\nKhong !");

	bool check2 = khuDeQuy(n);
	if(check2)
		printf("\nToan chu so le!");
	else
		printf("\nKhong !");

	getch();
	return 0;
}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
Line 17: error: conio.h: No such file or directory
Line 4: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'deQuy'
Line 13: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ToanChuSoLe'
Line 20: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'khuDeQuy'
In function 'main':
Line 39: error: 'bool' undeclared (first use in this function)
Line 39: error: (Each undeclared identifier is reported only once
Line 39: error: for each function it appears in.)
Line 39: error: expected ';' before 'check1'
Line 40: error: 'check1' undeclared (first use in this function)
Line 45: error: expected ';' before 'check2'
Line 46: error: 'check2' undeclared (first use in this function)


Create a new paste based on this one


Comments: