1 solutions
-
0
C :
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<ctype.h> #include<math.h> char s[10001],t[1]; int x,m; void f(int x){ if(x==0) return; else if(x%m>=10){ t[0] = x%m-10+'A'; }else{ t[0] = x%m+'0'; } strcat(s,t); f(x/m); } int main(){ int i; scanf("%d%d",&x,&m); if(x==0){ printf("%d",0); return 0; } f(x); for(i=strlen(s)-1;i>=0;i--) printf("%c",s[i]); return 0; }
C++ :
#include<bits/stdc++.h> using namespace std; string pa(string y,int x,int m){ int k=x%m; if(k>=0 && k<=9){ y=char(k+'0')+y; }else if(k>=10 && k<=15){ y=char(k-10+'A')+y; } x=x/m; if(x>0){ return pa(y,x,m); }else{ return y; } } int main(){ long long x; int m; cin>>x>>m; if(x==0){ cout<<0; return 0; } string y=""; cout<<pa(y,x,m); return 0; }
- 1
Information
- ID
- 631
- Time
- 1000ms
- Memory
- 16MiB
- Difficulty
- 10
- Tags
- # Submissions
- 7
- Accepted
- 3
- Uploaded By