[ create a new paste ] login | about

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

C, pasted on May 19:
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<string.h>
const int MenhGia[] = {500000, 200000, 100000, 50000, 20000, 10000, 5000, 2000, 1000, 500};
const int nMenhGia = sizeof(MenhGia) / sizeof(MenhGia[500]);

void TinhTienThoi(int Gia, int TienTra)
{
	
	int TienThoi = TienTra - Gia;
	if (TienTra < Gia)
	{
		printf("\nKhong du tien thoi! ");
	}
	else if (TienTra == Gia)
	{
		printf("\nKhong can phai thoi! ");
	}
	else
	{
		printf("\nSo tien phai thoi lai gom: ");
		for (int i = 0; i < nMenhGia - 1; i++)
		{
			int temp = TienThoi / MenhGia[i];
			if (temp > 0)
			{
				TienThoi = TienThoi % MenhGia[i];
			}
			printf("\ %d to  %d + ", temp,MenhGia[i]);
		}

	}
	
}
int main()
{
	/*int Gia, int TienTra;
	printf("\nSo tien cua mon hang: %d",Gia);
	scanf_s("%d", &Gia);
	printf("\nSo tien khach hang tra: %d", TienTra);
	scanf_s("%d", &TienTra);*/


	TinhTienThoi(169000,200000);
	_getch();
	return 0;
}


Output:
1
2
3
4
Line 17: error: conio.h: No such file or directory
In function 'TinhTienThoi':
Line 23: error: 'for' loop initial declaration used outside C99 mode
Line 10: warning: unknown escape sequence: '\040'


Create a new paste based on this one


Comments: