#include<stdio.h>voidmain(){inta[10],i,n,j,k=0;printf("請輸入一個正整數:")
;scanf("%d",&n);for(i=0;i<=9;i++){j=n%10;a[i]=j;n=(n-(n%10))/10;k=k+1;if(n<1)break;}printf("將該正整數倒序輸出:")
;for(i=0;i<=k-1;i++)printf("%d",a[i]);
}運行示例:生成的可執(zhí)行文件:
#include<stdio.h>voidmain(){inta[10],i,n,j,k=0;printf("請輸入一個正整數:")
;scanf("%d",&n);for(i=0;i<=9;i++){j=n%10;a[i]=j;n=(n-(n%10))/10;k=k+1;if(n<1)break;}printf("將該正整數倒序輸出:")
;for(i=0;i<=k-1;i++)printf("%d",a[i]);
}運行示例:生成的可執(zhí)行文件: