S
Sheriff92
#include"stdafx.h"
#include<conio.h>
#include<math.h>
int _tmain()
{
int tch, z0;
double n=0, f=1, S=0, eps, z, k, m, R, A=0.0647324, B=0.4382591;
printf("\n Viberite tochnost eps:1=10^-3; 2=10^-6; 3=10^-8\n");
scanf("%i", &tch);
switch (tch)
{
case 1: eps=0.001; break;
case 2: eps=0.000001; break;
case 3: eps=0.00000001; break;
default: puts("Vvedite chislo v diapasone 1..3");
}
printf("\n Viberite z: 1=0.5; 2=1\n");
scanf("%i", &z0);
switch (z0)
{
case 1: z=0.5; break;
case 2: z=1; break;
default: puts("Vvedite 1 ili 2");
}
k=1;
while(fabs(k)>=eps)
{
S=S+k;
n=n+1;
f=(2*n+1)*n;
m=pow(-1,n)*pow(3.14/2,2*n+1)*pow(z,4*n+3);
k=m/(f*(4*n+3));
}
printf("\n Summa ryada=%lf", S);
if(z==0.5)
R=A-S;
else
if(z==1)
R=B-S;
if(fabs®<0.1)
printf("\n Poluchennoe znachenie sovpadaet s kontrolnim");
else
printf("\n Poluchennoe znachenie ne sovpadaet s kontrolnim");
_getch();
}
#include<conio.h>
#include<math.h>
int _tmain()
{
int tch, z0;
double n=0, f=1, S=0, eps, z, k, m, R, A=0.0647324, B=0.4382591;
printf("\n Viberite tochnost eps:1=10^-3; 2=10^-6; 3=10^-8\n");
scanf("%i", &tch);
switch (tch)
{
case 1: eps=0.001; break;
case 2: eps=0.000001; break;
case 3: eps=0.00000001; break;
default: puts("Vvedite chislo v diapasone 1..3");
}
printf("\n Viberite z: 1=0.5; 2=1\n");
scanf("%i", &z0);
switch (z0)
{
case 1: z=0.5; break;
case 2: z=1; break;
default: puts("Vvedite 1 ili 2");
}
k=1;
while(fabs(k)>=eps)
{
S=S+k;
n=n+1;
f=(2*n+1)*n;
m=pow(-1,n)*pow(3.14/2,2*n+1)*pow(z,4*n+3);
k=m/(f*(4*n+3));
}
printf("\n Summa ryada=%lf", S);
if(z==0.5)
R=A-S;
else
if(z==1)
R=B-S;
if(fabs®<0.1)
printf("\n Poluchennoe znachenie sovpadaet s kontrolnim");
else
printf("\n Poluchennoe znachenie ne sovpadaet s kontrolnim");
_getch();
}