#include <stdio.h>
#include <curses.h>
#define MAX 100
#define MLEN 19
int old[20]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
char new[20]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j'};
int main()
{
char put[MAX];
char ch;
int i,j,count=0,count1=0;
int pnew1[MAX],pnew2[MAX];
char result[MAX+1];
int flag=0,sum=0;
printf("please input frist number:");
scanf("%s",&put);
for(i=0;i<MAX;i++)
{
if(put[i]=='\0')
break;
for(j=0;j<=MLEN;j++)
{
if(put[i]==new[j])
{
pnew1[i]=old[j];
break;
}
}
count++;
}
printf("please input second number:");
scanf("%s",&put);
for(i=0;i<MAX;i++)
{
if(put[i]=='\0')
break;
for(j=0;j<=MLEN;j++)
{
if(put[i]==new[j])
{
pnew2[i]=old[j];
break;
}
}
count1++;
}
if(count!= count1)
return 0;
for(i=count-1;i>=0;i--)
{
sum=pnew1[i]+pnew2[i]+flag;
result[i+1]=new[sum%(MLEN+1)];
flag=sum/(MLEN+1);
printf("result:%c\n",result[i+1]);
}
result[0]=new[flag];
for(i=0;i<count+1;i++)
printf("%c",result[i]);
printf("\n");
}
编程是为了提高效率,好的程序是因为他的高效;在编程的道路上,永远追逐高效的算法