Fix the invisible null value not transferring over in mult
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
2b11336692
commit
f2d1e25c3d
11
src/main.c
11
src/main.c
@ -1,5 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Consider all integer combinations of ab for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5:
|
Consider all integer combinations of ab for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5:
|
||||||
@ -18,6 +19,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int main(int argc,char**argv) {
|
int main(int argc,char**argv) {
|
||||||
printf("%s",BigPow(3,7).str);
|
struct String*numbs=malloc(sizeof(struct String)*0);
|
||||||
|
int arrSize=0;
|
||||||
|
for (int a=2;a<=5;a++) {
|
||||||
|
for (int b=2;b<=20;b++) {
|
||||||
|
numbs=realloc(numbs,sizeof(struct String)*++arrSize);
|
||||||
|
numbs[arrSize-1]=BigPow(a,b);
|
||||||
|
printf("\n%s\n",numbs[arrSize-1].str);
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -43,17 +43,17 @@ struct String mult(struct String numb1, struct String numb2) {
|
|||||||
val[j]=addends[i][j]+'0';
|
val[j]=addends[i][j]+'0';
|
||||||
}
|
}
|
||||||
sum=add((struct String){n1.length+1+i,val},sum);
|
sum=add((struct String){n1.length+1+i,val},sum);
|
||||||
//printf("%s\n",sum.str);
|
printf("\nAA:%s",sum.str);
|
||||||
}
|
}
|
||||||
if (sum.str[0]=='0') {
|
if (sum.str[0]=='0') {
|
||||||
char*newStr=malloc(sum.length-1);
|
char*newStr=malloc(sum.length);
|
||||||
for (int i=1;i<sum.length;i++) {
|
for (int i=1;i<sum.length+1;i++) {
|
||||||
newStr[i-1]=sum.str[i];
|
newStr[i-1]=sum.str[i];
|
||||||
}
|
}
|
||||||
free(sum.str);
|
free(sum.str);
|
||||||
sum=(struct String){sum.length-1,newStr};
|
sum=(struct String){sum.length-1,newStr};
|
||||||
}
|
}
|
||||||
//printf("%s",sum.str);
|
printf("\nA:%s",sum.str);
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user