[ create a new paste ] login | about

Link: http://codepad.org/iIATtpAW    [ raw code | output | fork | 1 comment ]

C, pasted on Aug 22:
#include<stdio.h>
#include<conio.h>

int main()
{
	int n;
	// Nhập n ( n > 0 )
	do
	{
		printf("\nNhap vao n ( n > 0 ): ");
		scanf_s("%d", &n);

		if (n <= 0)
		{
			printf("\nGia tri ban nhap vao khong hop le. Xin vui long nhap lai! ");
		}

	} while (n <= 0);

	bool CheckGiamDan = true;
	int themang = n;
	int ChuSoCuoi = themang % 10;  // lấy ra chữ số cuối
	themang /= 10;

	printf("\nCac chu so cua %d co giam dan tu trai sang phai khong ?\n ", n);
	while(themang != 0)
	{
		int ChuSoKeCuoi = themang % 10;
		themang /= 10;
		if (ChuSoKeCuoi < ChuSoCuoi)
		{
			CheckGiamDan = false;
			break;
		}
		else
		{
			ChuSoCuoi = ChuSoKeCuoi;  // Cập nhật lại chữ số cho lần so sánh tiếp theo
		}
	}
	if(CheckGiamDan)
		printf("\Dung !");
	else
		printf("Sai !");
	

	getch();
	return 0;
}


Output:
1
2
3
4
5
6
7
8
9
Line 17: error: conio.h: No such file or directory
In function 'main':
Line 20: error: 'bool' undeclared (first use in this function)
Line 20: error: (Each undeclared identifier is reported only once
Line 20: error: for each function it appears in.)
Line 20: error: expected ';' before 'CheckGiamDan'
Line 32: error: 'CheckGiamDan' undeclared (first use in this function)
Line 32: error: 'false' undeclared (first use in this function)
Line 9: warning: unknown escape sequence '\D'


Create a new paste based on this one


Comments:
posted by 19127646 on Oct 27
#include <stdio.h>
int main()
{
int n;
scanf_s("%d", &n);
while (n != 0)
{
int k = n % 10;
n /= 10;
if (n == 0)
continue;
if (k > n%10)
{
printf(" ko giam dan "); return 0;
}
}
printf("giam dan");
return 0;
}
reply