O___o

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
Âàðèàíò 4
Âû÷èñëèòü è âûâåñòè íà ýêðàí â âèäå òàáëèöû çíà÷åíèÿ ôóíêöèè F íà èíòåðâàëå îò
Xíà÷. äî Xêîí. ñ øàãîì dX.
|-a*x - c ïðè c<0 è x íå=0
|
|x-a
|--- ïðè c>0 è x=0
F = | -c
|
|b*x
|--- â îñòàëüíûõ ñëó÷àÿõ
|c-a
ãäå a,b,c-äåéñòâèòåëüíûå ÷èñëà.
Ôóíêöèÿ F äîëæíà ïðèíèìàòü äåéñòâèòåëüíîå çíà÷åíèå, åñëè âûðàæåíèå
Àö ÈËÈ Âö ÈËÈ Ñö
íå ðàâíî íóëþ, è öåëîå çíà÷åíèå â ïðîòèâíîì ñëó÷àå. ×åðåç Àö, Âö è Ñö îáîçíà÷åíû
öåëûå ÷àñòè çíà÷åíèé a,b,c, îïåðàöèÿ ÈËÈ - ïîðàçðÿäíàÿ. Çíà÷åíèÿ a,b,c, Xíà÷.,
äî Xêîí., dX ââåñòè ñ êëàâèàòóðû.
*/
#include <iostream>
int main(void)
{
int a,b,c,F,xb,xe,dx,x;
std::cout << "Labwork 01 , var 04\n";
std::cout << "Golubnichiy S.A. group 2516\n";
std::cout << "---------------------------\n";
std::cout << "Please type a :";
std::cin >> a;
std::cout <<"\nPlease type c :";
std::cin >> c;
std::cout <<"\nPlease type begin of x :";
std::cin >> xb;
std::cout <<"\nPlease type end of x :";
std::cin >> xe;
std::cout <<"\nStep of x :";
std::cin >> dx;
std::cout << "----------------------------\n";
for(x=xb;xb > xe;xb+=dx)
{
//Ñëó÷àé ïåðâûé *** -a*x - c ïðè c<0 è x íå=0 ***
if(c < 0 && xb !=0)
{
F=(-a)*xb - c;
std::cout << "\nF:= " <<F<<"| Xb:= " <<xb<<"| Xe:= " <<xe<< " X:= " <<xb;
}
/*Ñëó÷àé âòîðîé *** |x-a
|--- ïðè c>0 è x=0
| -c
*/
else if(c > 0 && xb == 0)
{
F=(xb-a)/(-c);
std::cout << "\nF:= " <<F<<"| Xb:= " <<xb<<"| Xe:= " <<xe<< " X:= " <<xb;
}
/* Ñëó÷àé òðåòèé *** |b*x
|--- â îñòàëüíûõ ñëó÷àÿõ
|c-a
*/
else
{
if((c-a) != 0)
{
F=(b*xb)/(c-a);
std::cout << "\nF:= " <<F<<"| Xb:= " <<xb<<"| Xe:= " <<xe<< " X:= " <<xb;
}
else
std::cout << "\nF:= ERROR! c-a = 0!!!" <<F<<"| Xb:= " <<xb<<"| Xe:= " <<xe<< " X:= " <<xb;
}
}
system("pause");
return 0;
}