| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:求助,有特殊值么?In Reply To:求助,有特殊值么? Posted by:mll_world at 2013-01-20 19:39:00 #include"stdio.h"
#include"stdlib.h"
#include<ctype.h>
char a[100];
int i,j,n,m,sum,t;
void main()
{
for(;~scanf("%s%d%d",a,&n,&m);)
{
i=strlen(a);
sum=0;
if(i>7) printf(" ERROR");
else
{
for(j=0;j<i;j++)
{
a[j]=toupper(a[j]);
t=a[j]<57?a[j]-48:a[j]-55;
if(t<n)sum=n*sum+t;
else break;
}
for(n=0;;n++)
{
a[n]=sum%m;
a[n]+=a[n]>9?55:48;
sum=sum/m;
if(sum==0) break;
}
if(n>7) printf(" ERROR");
else
{
for(j=n+1;j<7;j++)
putchar(' ');
for(j=n;j>=0;j--)
printf("%c",a[j]);
}
}
putchar(10);
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator