//degree distribution with visibility transform
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <math.h>
usingnamespace std;
#define adatszam 3
int fokszam;
int i;
int a,b,c;
float ya,yb,yc;
float data[adatszam];
int k[adatszam];
FILE *inf, *outf;
int main() {
inf = fopen("proba.txt","r");
for (i=0; i<adatszam; i++)
{
fscanf(inf,"%d %f", &k[i], &data[i]);
}
fclose(inf);
for (i = 0; i < adatszam; ++i) {
fokszam = 0;
a = k[i];
ya = data[i];
for (int n = 0; n < adatszam; ++n) {
if (n==i) continue;
b = k[n];
yb = data[n];
int sz = 0;
if (i>n){
for (int a = n+1; a<i; a++) {
c = k[a];
yc = data[a];
if (yc < yb + (ya-yb)*((b-c)/(b-a)))
sz += 1;
if (sz==(i-n+1))
fokszam+=1;
}
}
else {
for (int a = n-1; a>i; a--) {
c = k[a];
yc = data[a];
if (yc < yb + (ya-yb)*((b-c)/(b-a)))
sz += 1;
if (sz==(i-n+1))
fokszam+=1;
}
}
ofstream myfile ("probagraf.txt");
if (myfile.is_open())
{
myfile << fokszam << '\n';
}
myfile.close();
}
}
cout << "Elkeszultem a kiertekelessel";
cin.get();
return 0;
}
It runs succesfully because i get the line "Elkeszultem a kiertekelessel" (at the end of the program, see in line 65).
If anyone have any idea why I got this obviously wrong result, pls help me out.
P.s.: if u need clarification about what sequence does what just ask!