Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #pragma warning(disable:4996)
- int main()
- {
- int sum = 0, sum2=0, sum3=0;
- printf("A = ");
- int array[1024];
- int length = 0;
- char buffer[1024];
- char *aux;
- fgets(buffer, 1023, stdin);
- aux = strtok(buffer, ",");
- while (aux)
- {
- array[length] = atoi(aux);
- length++;
- aux = strtok(NULL, ",");
- }
- for (int i = 0; i < length; i++)
- {
- sum = sum + (int) array[i];
- }
- printf("\n", sum);
- printf("B = ");
- int array2[1024];
- int length2 = 0;
- char buffer2[1024];
- char *aux2;
- fgets(buffer2, 1023, stdin);
- aux2 = strtok(buffer2, ",");
- while (aux2)
- {
- array2[length2] = atoi(aux2);
- length2++;
- aux2 = strtok(NULL, ",");
- }
- for (int j = 0; j < length2; j++)
- {
- sum2 = sum2 + (int)array2[j];
- }
- printf("\na = %d\n", sum);
- printf("\nb = %d\n", sum2);
- printf("\n\n");
- printf(" %d\n", sum);
- printf("+ %d\n", sum2);
- sum3 = sum + sum2;
- printf("-----\n");
- printf(" %d\n", sum3);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement