文章
4
粉丝
11
获赞
20
访问
931
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
void reverse(char *s){
int len = strlen(s);
for(int i = 0; i < len /2; i++){
char temp = s[i];
s[i] = s[len-i-1];
s[len-i-1] = temp;
}
}
//大数加法
void big_add(char *s1, char *s2, char *res){
int len1 = strlen(s1) - 1;
int len2 = strlen(s2) - 1;
int index = 0;
int carry = 0;
while(len1 >= 0 || len2 >= 0 || carry){
int sum = carry;
if(len1 >= 0) sum += s1[len1--] - '0';
if(len2 >= 0) sum += s2[len2--] - '0';
res[index++] = sum % 10 + '0';
carry = sum / 10;
&...
登录后发布评论
暂无评论,来抢沙发