hdu 1877 又一版 A+B (水)

点击打开链接

PS:wrong了一次,没注意0+0的情况,本题为简单的进制转换
#include<stdio.h>
#include<string.h>
	   int main()
   {
	   int a,b,m,k;
	   char s[222];
	   while(scanf("%d%d%d",&m,&a,&b),m!=0)
	   {
		   a+=b;k=0;
		   if(a==0)
		   {
			   printf("0\n");continue;
		   }
		   while(a)
		   {
			   s[k++]=a%m+'0';
			   a/=m;
		   }
		   s[k]='\0';
		   strrev(s);
		   puts(s);
	   }
	   return 0;
   }


posted on 2012-09-02 09:24  Slege  阅读(113)  评论(0编辑  收藏  举报

导航