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