Skip to content

Instantly share code, notes, and snippets.

@Evshved
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save Evshved/588c5e3e06ed95c5a56e to your computer and use it in GitHub Desktop.

Select an option

Save Evshved/588c5e3e06ed95c5a56e to your computer and use it in GitHub Desktop.
Implementation of round robin
#include <vcl.h> // Visual Component Library
#include <stdio.h> // standard input/output header
#include <conio.h> //console input-output
#include <math.h> //mathematics
#include <stdlib.h> //standard library
#pragma hdrstop
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
double a,b,x,h,r,s,f,razn;
int k,sign,n,count;
do {
clrscr();
fflush(stdin);
printf(" 1 - Example, others digits -your's inp\n");
scanf("%d",&sign);
if (sign==1) {
a=0.1; b=1.0; h=0.1;
n=10;
}
else {
do {
printf("print a,b,h,n\n");
fflush(stdin);
} while(scanf("%lf%lf%lf%d",&a,&b,&h,&n) != 4);
}
for (x=a; x<=b; x+=h) {
r=1;
s=0;
for (k=1; k<=n; k++) {
r=-r*4*x*x/((2*k-1)*2*k);
s+=r;
}
f=2*(cos(x)*cos(x)-1);
razn=fabs(f-s);
printf(" x = %lf, s = %lf\, f= %lf, razn= %lf \n",x,s,f,razn);
}
puts("Exit - 1, Restart - any key");
} while ( getch() != '1');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment