Untitled
unknown
c_cpp
3 years ago
637 B
7
Indexable
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include "function.h"
int solver(int **ptr, int *sum, char *s){
int len = strlen(s);
int j = 0, tmp = 0, pos = 1;
for(int i = 0; i <= len; i++){
if(tmp == 1 && (isdigit(s[i]) == 0 || i == len)){
*sum += *ptr[j];
tmp = 0, pos = 1;
j++;
}
if(s[i] == '-') pos = 0;
if(isdigit(s[i]) == 1){
tmp = 1;
if(pos == 1) *ptr[j] = (*ptr[j])*10 + s[i] - '0';
else *ptr[j] = (*ptr[j])*10 - (s[i]-'0');
}
}
return j;
}Editor is loading...