Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:求助,有特殊值么?

Posted by mll_world at 2013-01-20 19:39:40 on Problem 1546
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator