#include
#include int soChuSo(int n){
int dem=0;
while (n>0){
dem++;
n=n/10;
}
return dem;
}
int tinhTong(int n){
int tong=0;
while(n>0){
tong=tong+(n%10);
n=n/10;
}
return tong;
}
int daoNguoc(int n){
int mu = soChuSo(n)-1;
int kq=0;
while(n>0){
int m = (n%10)*pow(10,mu);
kq=kq+m;
n =n/10;
mu--;
}
return kq;
}
int main(){
int n;
printf("Nhap vao so nguyen n : ");
scanf("%d",&n);
int scs = soChuSo(n);
printf("So chu so (%d) = %d",n,scs);
int tcs = tinhTong(n);
printf("\nTong cac so trong so (%d) = %d",n,tcs);
int sdn = daoNguoc(n);
printf("\nDao nguoc(%d) = %d",n,sdn);
return 0;
}
0 nhận xét:
Đăng nhận xét