[ create a new paste ] login | about

Link: http://codepad.org/dzr2q4m2    [ raw code | output | fork | 2 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 chan hay khong ?\n", n);
	bool Check = true;
	while(n /= 10)
	{
		if((n % 10) % 2 == 1)
		{
			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 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 == 0){
cout<<"Chuoi toan so chan"<<
endl;

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

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

int main(){
int n;
int t;
int k;
int scs=0;
int scschan=0;
do
{
printf("Hay nhap vao n:\n");
scanf("%d",&n);
if(n<1)
{
printf("n phai lon hon bang 1. Hay nhap lai!\n");
}
}while(n<1);

t=n;

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

t=n;

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

if(scs==scschan)
{
printf("%d toan chu so chan",n);
}
else
{
printf("%d khong toan chu so chan",n);
}
return 0;
}

reply