Advertisement
llvlleo1810

Đổi chỗ chữ số đầu tiên và chữ số cuối cùng của một số

Apr 17th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 KB | None | 0 0
  1.  #include<stdio.h>
  2. int main(){
  3. int a[500],b[500];
  4. int n,count=0,count1=0,count3=0;
  5. scanf("%d",&n);
  6. while(n){
  7. a[count++]=n%10;
  8. n/=10;
  9. }
  10. b[count1++]=a[0];
  11. for(int i=count-2;i>0;i--){
  12. b[count1++]=a[i];  
  13. }
  14. b[count1++]=a[count-1];
  15. for(int i=0;i<count1;i++){
  16. if(b[i]==0) count3++;
  17. else break;
  18. }
  19. for(int i=count3;i<count1;i++){
  20. printf("%d",b[i]);
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement