[ create a new paste ] login | about

Link: http://codepad.org/tz6yfPJW    [ raw code | output | fork | 2 comments ]

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 CheckTangDan = true;
	int themang = n;
	int ChuSoCuoi = themang % 10;  // lấy ra chữ số cuối
	themang /= 10;

	printf("\nCac chu so cua %d co tang dan tu trai sang phai khong ?\n ", n);
	while(themang != 0)
	{
		int ChuSoKeCuoi = themang % 10;
		themang /= 10;
		if (ChuSoCuoi < ChuSoKeCuoi)
		{
			CheckTangDan = false;
			break;
		}
		else
		{
			ChuSoCuoi = ChuSoKeCuoi;  // Cập nhật lại chữ số cho lần so sánh tiếp theo
		}
	}
	if(CheckTangDan)
		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 'CheckTangDan'
Line 32: error: 'CheckTangDan' 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 khanhtienfz on Jul 8
#include <stdio.h>
#include <stdlib.h>

int main()
{

int n;
do{
printf("\nnhap n = ");
scanf_s("%d", &n);
if (n < 0)
{
printf("\nxin vui long nhap lai !!!");
}

} while (n < 0);
while (1)
{
int k = n % 10;
n /= 10;
int i = n % 10;
if (k < i)
{
continue;
}
else
{
printf("\nCac chu so nguyen duong n khong tang dan");

goto cmm;
}
}

printf("\nVay cac chu so nguyen duong cua n tang dan tu trai sang phai");

cmm:
printf("\n\n");
system("pause");
return 0;
}
reply
posted by maiphu.2510@gmail.com on Aug 14
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int n,k;

printf("\nNhap n = ");
scanf("%d",&n);
int max=n%10;
n=n/10;
while(n!=0)
{
k=n%10;
if(k>max)
{
printf("\nkhong phai tang dan ");
break;
}
else
{
max=k;
n=n/10;
if(n==0)
{
printf("\ntang dan deu");
}
}
}

getch();
return 0;
}
reply