nothing
[此贴子已经被作者于2006-3-6 20:17:24编辑过]
moon:先生您好!看看下面的对不对:
#include<conio.h>
#include<stdio.h>
#include<string.h>
int get_num(char c);
int main(void)
{
char num1[50]="123456789",num2[50]="123456",buffer[30]; int total[30];
int i,j,n1_len,n2_len,k=0,v,m;
n1_len=strlen(num1);
n2_len=strlen(num2);
if(n1_len<n2_len)
{
strcpy(buffer,num1);
strcpy(num1,num2);
strcpy(num2,buffer);
}
n1_len=strlen(num1);
n2_len=strlen(num2);
while(n1_len>0)
{
if(n2_len<=0)
total[k++]=get_num(num1[--n1_len]);
else
total[k++]=get_num(num1[--n1_len])+get_num(num2[--n2_len]);
}
for(v=0;v<=k-1;v++)
if(total[v]>=10)
{
m=total[v]/10;
total[v+1]=total[v+1]+m;
total[v]=total[v]%10;
}
for(i=k-1;i>=0;i--)
printf("%3d",total[i]); printf("\n");
getch();
return 0;
}
int get_num(char c)
{
char string[10]="0123456789";
int i;
for(i=0;i<10;i++)
if(string[i]==c)
break;
return i;
}
自己写的四则运算的小程序,那时还没有学过编程规范,很乱,献丑了
[此贴子已经被作者于2006-3-7 13:17:35编辑过]