[ create a new paste ] login | about

Link: http://codepad.org/LVGQ1fe9    [ raw code | output | fork | 3 comments ]

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

int main(){
	int So;  // Khai báo
	printf("Nhap vao so = ");
	scanf("%d", &So);
	if (So < 100 || So > 999){
		printf("\nKhong hop le !");
		getch();
		return 0;
	}
	else  // Hợp lệ
	{
		// Xử lý
		// 123
		int donvi = So % 10;
		So /= 10;  // 12
		int chuc = So % 10;
		int tram = So / 10;

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

		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("Lam");
		}
		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 yonnon on Jul 17
mấy bài này lười làm quá :))

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

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

if (tram == 1)
{
cout << ("Mot");
}

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

}
//chuc
cout << (" Tram ");

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");

}
else if ( chuc == 0 )
{
cout << "Le";
}

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 21521809@gm.uit.edu.vn on Dec 16

#include <iostream>

using namespace std;

int main()
{
int n,dv,chuc,tram,nghin;
cout<<"nhap so nguyen co ba chu so : ";
cin>>n;
while(n!=0){

if(n>=1000){
dv=n%10;
n=n/10;
}
else if(n>=100){
chuc=n%10;
n=n/10;
}
else if(n>=10){
tram=n%10;
n=n/10;

}
else if(n>=1){
nghin=n%10;
n=n/10;
}
}
cout<<nghin<<" nghin "<<tram<<" tram "<<chuc<<" muoi "<<dv;
return 0;
}

reply