[ create a new paste ] login | about

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

C, pasted on Apr 26:
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
	int n;
	do
	{
		printf("\nNhap vao so nguyen duong n = ");
		scanf_s("%d", &n);
		if (n < 0)
		{
			printf("\nGia tri n phai lon hon 0. Xin vui long kiem tra lai!");
		}

	} while (n < 0);

	int SoLuongChuSo = n == 0 ? 1 : (int)log10((float)n) + 1;

	int chuSoMin, chuSoMax;
	chuSoMin = chuSoMax = n % 10;
	n /= 10;

	while (n != 0)
	{
		int chuso = n % 10;
		n /= 10;

		if (chuso > chuSoMax)
		{
			chuSoMax = chuso;
		}
		if (chuso < chuSoMin)
		{
			chuSoMin = chuso;
		}
	}
	printf("\nSo luong chu so = %d", SoLuongChuSo);
	printf("\nChu so Max = %d", chuSoMax);
	printf("\nChu so Min = %d", chuSoMin);

	_getch();
	return 0;
}


Output:
1
Line 17: error: conio.h: No such file or directory


Create a new paste based on this one


Comments: