35 lines
583 B
C
35 lines
583 B
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
|
|
#define LINES 1000
|
|
|
|
int parse_numbers(char *mulString, int *a, int *b)
|
|
{
|
|
int i = 4;
|
|
while (mulString[i] >= '0' && mulString[i] <= '9') {
|
|
*a = *a * 10 + mulString[i] - '0';
|
|
i++;
|
|
}
|
|
i++;
|
|
while (mulString[i] >= '0' && mulString[i] <= '9') {
|
|
*b = *b * 10 + mulString[i] - '0';
|
|
i++;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
int sum = 0;
|
|
char mulString[32];
|
|
|
|
FILE *input;
|
|
input = fopen("./inputDemo", "r");
|
|
int a = 0;
|
|
int b = 0;
|
|
while (fscanf(input, "%d,%d", &a, &b)) {
|
|
sum += a * b;
|
|
}
|
|
printf("%d, %d\n", a, b);
|
|
printf("%d\n", sum);
|
|
}
|