Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int kp(FILE* f)
- {
- int sum = 0;
- int num;
- while(fscanf(f,"%d", &num) != EOF)
- {
- if(num < 0)
- sum += num;
- }
- fclose(f);
- return sum;
- }
- int ab(char c, FILE* f)
- {
- int count = 0;
- char x;
- while(fscanf(f, "%c", &x) != EOF)
- {
- if(c == x)
- count++;
- }
- fclose(f);
- return count;
- }
- int main()
- {
- FILE *f;
- char x;
- int result1, result2;
- scanf("%c", &x);
- fp = fopen("D:\\Tst1.txt", "r");
- result1 = kp(f);
- printf("Otricatelni: %d\n", result1);
- fp = fopen("D:\\Tst1.txt", "r");
- result2 = ab(x, f);
- printf("Suma: %d\n", result2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement