链接http://acm.swust.edu.cn/problem/318/
#include <stdio.h> int arr[33]; int main() { int x; int i,j; while(scanf("%d",&x)!=EOF) { int y; y=x; i=j=0; if(x==0) { printf("0\n0\n"); } else { while(x!=0) { arr[i]=x%2; x=x/2; i++; } for(i=i-1;i>=0;i--) { printf("%d",arr[i]); } printf("\n"); while(y!=0) { arr[j]=y%8; y=y/8; j++; } for(j=j-1;j>=0;j--) { printf("%d",arr[j]); } printf("\n"); } } return 0; }
#include <stdio.h> int arr[33]; int main() { int x; int i,j; while(scanf("%d",&x)!=EOF) { int y; y=x; i=j=0; if(x==0) { printf("0\n0\n"); } else { while(x!=0) { arr[i]=x%2; x=x/2; i++; } for(i=i-1;i>=0;i--) { printf("%d",arr[i]); } printf("\n"); printf("%o\n",y); } } return 0; }
时间: 2024-10-19 09:21:20