Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- float duzina(float, float);
- int main(int argc, char **argv)
- {
- FILE *fp, *ffpp;
- int br=0;
- float x,y,r;
- fp=fopen("krugovi.dat", "r");
- if (fp==NULL) {
- printf("Nem're otvor't citanku!\n");
- getchar();
- return 0;
- }
- else {
- printf("Utvorio citanku!\n");
- ffpp=fopen("rezultat.txt", "w");
- if (ffpp==NULL) {
- printf("Nem're otvor't pisaljku!\n");
- getchar();
- return 0;
- }
- else {
- printf("Otvorio pisaljku!\n");
- while(!feof(fp)) {
- fscanf(fp, "(%f,%f,%f)\n", &x, &y, &r);
- if(duzina(x,y)>r)
- br++;
- }
- fprintf(ffpp, "Trazeni broj krugova je: %d\n", br);
- fflush(ffpp);
- rewind(fp);
- while(!feof(fp)) {
- fscanf(fp, "(%f,%f,%f)\n", &x, &y, &r);
- if(duzina(x,y)>r)
- fprintf(ffpp, "(%.2f,%.2f,%.2f)\n", x, y, r);
- }
- fclose(fp);
- printf("Zatvorio citanku!\n");
- }
- fclose(ffpp);
- printf("Zatvorio pisaljku!\n");
- }
- getchar();
- return 0;
- }
- float duzina(float x, float y) {
- return (sqrt(x*x + y*y));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement