Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- int n;
- int total;
- int array1[1000];
- int array2[1000];
- int main()
- {
- int i, j;
- int cho;
- FILE *f = fopen("expreval.txt", "r");
- if (f == NULL)
- printf("FILE ERROR\n");
- else
- {
- fscanf(f, "%d", &n);
- for (i = 1; i <= n; i++)
- {
- fscanf(f, "%d", &array1[i]);
- }
- for (j = 1; j < n; j++)
- {
- fscanf(f, "%d", &array2[j]);
- }
- }
- for (i = 1; i <= n; i++)
- for (j = 1; j < n; j++)
- {
- if (array2[j] == 2)
- {
- cho = array1[i] * array1[i + 1];
- }
- if (array2[j] == 2 && array2[j + 1] == 2)
- {
- cho = array1[i] * array1[i + 1];
- cho = cho * array1[i + 2];
- }
- }
- printf("%d\n", cho);
- return 0;
- }
Add Comment
Please, Sign In to add comment