[ create a new paste ] login | about

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

C, pasted on Aug 22:
#include<stdio.h>
#include<conio.h>

int main()
{

	int n;
	do
	{
		printf("\nNhap n(n >= 0): ");
		scanf("%d", &n);
		if(n < 0)
		{
			printf("\nN phai >= 0. Xin nhap lai !"); 
		}
	}while(n < 0);

	
	printf("\nSo %d gom toan cac chu so le hay khong ?\n", n);
	bool Check = true;
	while(n /= 10)
	{
		if((n % 10) % 2 == 0)
		{
			Check = false;
		    break;
		}
	}
	if(Check == true)
	{
		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 'Check'
Line 25: error: 'Check' undeclared (first use in this function)
Line 25: error: 'false' undeclared (first use in this function)
Line 29: error: 'true' undeclared (first use in this function)


Create a new paste based on this one


Comments:
posted by khanhtienfz on Jun 25
include<stdio.h>
#include<stdlib.h>

int main()
{

int n;
do
{
printf("\nNhap n(n >= 0): ");
scanf_s("%d", &n);
if (n < 0)
{
printf("\nN phai >= 0. Xin nhap lai !");
}
} while (n < 0);
do{

int k = n % 10;

if (k % 2 == 1)
{
continue;
}

if (k % 2 == 0)
{
printf("\nCac chu so cua so nguyen duong n khong le hoan toan");
goto Khaipro;
}

} while (n /= 10);

printf("\nCac chu so cua so nguyen duong cua n toan le ");

Khaipro:
printf("\n\n");
system("pause");
return 0;

}

reply
posted by maiphu.2510@gmail.com on Aug 13
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int n;
int s;
printf("\nNhap n = ");
scanf("%d",&n);

int t=n;
while(n!=0)
{
s=(n%10);
if(s%2==1)
{
printf("\n%d khong hoan toan la chu so chan",t);
break;
}
else
{
n=(n/10);
if(n==0)
{
printf("\n%d hoan toan la chu so chan",t);
}

}
}

getch();
return 0;
}

reply
posted by tanghocle456@gmail.com on Aug 8
#include <iostream>

using namespace std;

int main() {
int n,i=0,k,m=0;

do{
cout << "Nhap n (n>=0): " << endl;
cin >> n;
}while(n<=0 && cout << "Sai dieu kien.."<< endl);

while(n != 0) {
k = n%10;
i++;
if(k%2 != 0) {
m++;
}
n/=10;
}
if(i==m) cout << 1;
else cout << 0;

return 0;
}

reply
posted by minhnhut18c on Nov 10
#include <iostream>
#include<conio.h>

using namespace std;

void main()
{

int n, i = 0, k, m = 0;

do
{

cout << "Nhap n (n>=0): " << endl;
cin >> n;
if (n <= 0)
cout << "sai nhap lai" << endl;
} while (n <= 0);

while (n != 0) {
k = n % 10;
i++;
if (k % 2 != 0) {
m++;
}
n /= 10;
}
if (i == m) cout << "la so le" << endl;
else cout << "la so chan" << endl;

_getch();
}
reply
posted by 19127646 on Oct 27
#include <stdio.h>
int main()
{
int n;
int dem = 0;
scanf_s("%d", &n);
int max = n % 10;
while (n != 0)
{
int k = n % 10;
if (k % 2 == 0)
{
printf(" ko toan le "); return 0;
}
n /= 10;
}
printf("toan le");
return 0;
}
reply
posted by yonnon on Jul 9
#include<bits/stdc++.h>

struct S{
int number;
};
using namespace std;
int main(){
int n;
cout << "Enter your sentence: ";
cin >> n;
int *p;
p=&n;
int n2,temp2=0;
n2=*p;
S *temp=new S[n];
do{
temp2++;
n2/=10;

}while(n2!=0);
for(int i=0; i<temp2;++i){
temp[i].number=n%10;
n/=10;
}
int text=0;
for(int i=0; i<temp2; ++i){
if(temp[i].number%2!=0){
text++;
}

}
if(text == temp2){
cout<<"Chuoi toan so le"<<
endl;

}
else if(text != temp2){
cout<<"Chuoi khong toan so le"<<
endl;
}

delete[] temp;
return 0;
}
reply
posted by cuong.luucb8921 on Aug 21
#include<stdio.h>

int main(){
int n;
int t;
int s1, s2;
int scs=0;
int scsle=0;
do
{
printf("Nhap vap n:\n");
scanf("%d",&n);
if(n < 1)
{
printf("n phai lon hon bang 1\n");
}
}while(n < 1);

t = n;
while(t!=0)
{
s1 = t%10;
t = t/10;
scs = scs + 1;
}

t=n;

while(t!=0)
{
s2 = t%10;
t = t/10;
if(s2%2==1)
{
scsle = scsle + 1;
}
}

if(scsle==scs)
{
printf("%d toan chu so le",n);
}
else
{
printf("%d khong toan chu so le",n);
}
return 0;
}
reply
posted by 20223768 on Sep 12
#include <iostream>
using namespace std;
int main()
{
int n;cin >>n;
int s=1;
int dem=0;
while(n!=0)
{
s=n%10;
if(s%2==0) dem++;
n=n/10;
}
if (dem==0) cout << " co toan chu so le";
else cout << " co ca chu so le va chu so chan";
return 0;
}
reply