[ create a new paste ] login | about

Link: http://codepad.org/8rJH32tO    [ raw code | output | fork | 4 comments ]

C, pasted on Sep 11:
#include<stdio.h>
#include<conio.h>

int main(){
	int So;  // Khai báo
	printf("Nhap vao so = ");
		scanf_s("%d", &So);
	if (So < 10 || So > 99){
		printf("\nKhong hop le !");
		getch();
		return 0;
	}
	else  // Hợp lệ
	{  
		// Xử lý
		// 15 --> Muoi Lam
		int donvi = So % 10;
		int chuc = So / 10;

		if (chuc == 2)
		{
			printf("Hai");
		}
		else if (chuc == 3)
		{
			printf("Ba");
		}
		else if (chuc == 4)
		{
			printf("Bon");
		}
		else if (chuc == 5)
		{
			printf("Nam");
		}
		else if (chuc == 6)
		{
			printf("Sau");
		}
		else if (chuc == 7)
		{
			printf("Bay");
		}
		else if (chuc == 8)
		{
			printf("Tam");
		}
		else if (chuc == 9)
		{
			printf("Chin");
		}
		printf(" Muoi ");

		if (donvi == 1)
		{
			printf("Mot");
		}
		else if (donvi == 2)
		{
			printf("Hai");
		}
		else if (donvi == 3)
		{
			printf("Ba");
		}
		else if (donvi == 4)
		{
			printf("Bon");
		}
		else if (donvi == 5)
		{
			printf("Nam");
		}
		else if (donvi == 6)
		{
			printf("Sau");
		}
		else if (donvi == 7)
		{
			printf("Bay");
		}
		else if (donvi == 8)
		{
			printf("Tam");
		}
		else if (donvi == 9)
		{
			printf("Chin");
		}
	}
	getch();
	return 0;
}


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


Create a new paste based on this one


Comments:
posted by manhha on Mar 1
Don vi == 0 >> == 9;
reply
posted by manhha on Mar 1
#include <stdio.h>
#include <conio.h>
int main()
{
int so;
printf("Nhap vao so \n");
scanf("%d", &so);
if (so < 10 || so > 99)
{
printf("So co 2 chu so, xin nhap lai!");
return (so<10 || so > 99);
}
else
{

int donvi = so % 10;
int chuc = so / 10;
if (chuc == 1)
{
if( so < 10)
printf("Mot ");
else
printf("Muoi ");
}
else if (chuc == 2)
{
printf("Hai ");
}
else if (chuc == 3)
{
printf("Ba ");
}
else if (chuc == 4)
{
printf("Bon ");
}
else if (chuc == 5)
{
printf("Nam ");
}
else if (chuc == 6)
{
printf("Sau ");
}
else if (chuc == 7)
{
printf("Bay ");
}
else if (chuc == 8)
{
printf("Tam ");
}
else if (chuc == 9)
{
printf("Chin ");
}
else
{
printf("Muoi ");
}
if (donvi == 0)
{
printf("Muoi");
}

else if (donvi == 1)
{
printf("Mot");
}
else if (donvi == 2)
{
printf("Hai");
}
else if (donvi == 3)
{
printf("Ba");
}
else if (donvi == 4)
{
printf("Bon");
}
else if (donvi == 5)
{
printf("Nam");
}
else if (donvi == 6)
{
printf("Sau");
}
else if (donvi == 7)
{
printf("Bay");
}
else if (donvi == 8)
{
printf("Tam");
}
else if (donvi == 9)
{
printf("Chin");
}
}
getch();
return 0;
}

reply
posted by yonnon on Jul 17
#include<bits/stdc++.h>

using namespace std;
int main()
{
int n;
int chuc;
int donvi;
do
{
cout << "Enter your sentence: ";
cin >> n;
if( n < 10 || n > 99 )
{
cout << "You wrong, Try again!"<<
endl;
}
}while( n < 10 || n > 99 );

chuc = n / 10;
donvi = n % 10;

if (chuc == 2)
{
cout << ("Hai");
}
else if (chuc == 3)
{
cout << ("Ba");
}
else if (chuc == 4)
{
cout << ("Bon");
}
else if (chuc == 5)
{
cout << ("Nam");
}
else if (chuc == 6)
{
cout << ("Sau");
}
else if (chuc == 7)
{
cout << ("Bay");
}
else if (chuc == 8)
{
cout << ("Tam");
}
else if (chuc == 9)
{
cout << ("Chin");
}
cout << (" Muoi ");

if (donvi == 1)
{
cout << ("Mot");
}
else if (donvi == 2)
{
cout << ("Hai");
}
else if (donvi == 3)
{
cout << ("Ba");
}
else if (donvi == 4)
{
cout << ("Bon");
}
else if (donvi == 5)
{
cout << ("Nam");
}
else if (donvi == 6)
{
cout << ("Sau");
}
else if (donvi == 7)
{
cout << ("Bay");
}
else if (donvi == 8)
{
cout << ("Tam");
}
else if (donvi == 9)
{
cout << ("Chin");
}

cin.ignore();

return 0;

}
reply
posted by hiii_02102002 on Mar 8
//Viết chương trình nhập một số nguyên có hai chữ số. Hãy in ra cách
//đọc của số nguyên này
#include<iostream>
using namespace std;
void DocSo(int n)
{
int HangDonvi = n % 10;
int HangChuc = n / 10;
switch (HangChuc)
{
case 1:
cout << "Muoi"; break;
case 2:
cout << "Hai Muoi"; break;
case 3:
cout << "Ba Muoi"; break;
case 4:
cout << "Bon Muoi"; break;
case 5:
cout << "Nam Muoi"; break;
case 6:
cout << "Sau Muoi"; break;
case 7:
cout << "Bay Muoi"; break;
case 8:
cout << "Tam Muoi"; break;
case 9:
cout << "Chin Muoi"; break;
}
switch (HangDonvi)
{
case 1:cout << " Mot"; break;
case 2:cout << " Hai"; break;
case 3:cout << " Ba"; break;
case 4:cout << " Bon"; break;
case 5:cout << " Lam"; break;
case 6:cout << " Sau"; break;
case 7:cout << " Bay"; break;
case 8:cout << " Tam"; break;
case 9:cout << " Chin"; break;
}
}
int main()
{
int n;
do
{
cout << "Nhap So Co Hai Chu So ! "; cin >> n;
} while (n<10||n>99);
DocSo(n);
return 0;
}
reply