Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int paralela(void) {
- FILE *p, *f;
- char otp[200];
- int i;
- float rjesenje, zbroj = 0;
- p = fopen("otpori.txt", "r");
- if (p == NULL) {
- return 0;
- }
- else {
- f = fopen("rezultat.txt", "w+");
- if (f == NULL) {
- return 0;
- }
- }
- while (fscanf(p, "%s", otp) == 1) {
- i = atoi(otp);
- zbroj += 1.0/i;
- //zbroj += (float)1/i;
- }
- rjesenje = 1 / zbroj;
- fprintf(f, "%f", rjesenje);
- fclose(p);
- fclose(f);
- return 1;
- }
- int main(void) {
- if (paralela()) {}
- else printf("greska...");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment