,  ,

Delphi


 
 
barmatun
0 / 0 / 0
: 31.05.2012
: 6
#1

case - Delphi

31.05.2012, 02:23. 605. 10
( )

. (undeclared identidier), , .

function f(x:real):real;
var y:real;
begin
case RadioDataGroup.itemindex of
0:y:=sinx(x)
1:y:=cosx(x)
result:=y
end;
end;

Function sinx(x: real): real;

var
y: real;
i: integer;
begin
y := 0;
for i := Np downto 1 do
y := sin(x);
Result := y;
end;

Function cosx(x: real): real;

var
y: real;
i: integer;
begin
y := 0;
for i := Np downto 1 do
y := sin(x);
Result := y;
end;
0
? .
Similar
41792 / 34177 / 6122
: 12.04.2006
: 57,940
31.05.2012, 02:23
! case (Delphi):

case - Delphi
case: 20-69, ( ). -...

case - Delphi
case: (""-, ""-, ""-, ""-) ...

( ) ? - Delphi
: Procedure CalkRetn; begin Retn:= ??????; end; // CalkRetn; ...

- C++
! : . , ...

case - C++
, , case? ? ...

switch Case bypasses initialization of a local variable - C++
case 3, , Case bypasses initialization of a...

10
vilag
69 / 68 / 2
: 24.05.2012
: 146
31.05.2012, 02:34 #2

Pascal
1
f := sinx(x);
-?
0
barmatun
0 / 0 / 0
: 31.05.2012
: 6
31.05.2012, 02:39  [] #3
case RadioDataGroup.itemindex of
0
vilag
69 / 68 / 2
: 24.05.2012
: 146
31.05.2012, 02:41 #4
? RadioDataGroup. , Form1.RadioDataGroup - .

, , .
0
barmatun
0 / 0 / 0
: 31.05.2012
: 6
31.05.2012, 02:44  [] #5
[QUOTE=vilag;3105169]
Pascal
1
f := sinx(x);
, , , (RadioDataGroup: TRadioGroup

55
?
0
vilag
69 / 68 / 2
: 24.05.2012
: 146
31.05.2012, 02:44 #6
. - . , , .
[DELPHI][/DELPHI]
0
barmatun
0 / 0 / 0
: 31.05.2012
: 6
31.05.2012, 02:45  [] #7

Delphi
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
unit main;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, Buttons, XPMan, ActnList, ComCtrls, ToolWin,
  ImgList, Menus;
 
type
  TForm1 = class(TForm)
    Panel2: TPanel;
    Image1: TImage;
    XPManifest1: TXPManifest;
    ToolBar1: TToolBar;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    ActionList1: TActionList;
    aDraw: TAction;
    aExit: TAction;
    aAbout: TAction;
    aData: TAction;
    ImageList1: TImageList;
    MainMenu1: TMainMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    N3: TMenuItem;
    N4: TMenuItem;
    N5: TMenuItem;
    N6: TMenuItem;
    N7: TMenuItem;
    N8: TMenuItem;
    RadioDataGroup: TRadioGroup;
    procedure cmdExit(Sender: TObject);
    procedure cmdDraw(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure aDataExecute(Sender: TObject);
    procedure aAboutExecute(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
uses data, about;
 
{$R *.dfm}
function f(x:real):real;
  var y:real;
  begin
    case RadioDataGroup.itemindex of
    0:y:=sinx(x)
    1:y:=cosx(x)
   end;
   result:=y
end;
 
 
Function sinx(x: real): real;
//âû÷èñëå*èå ç**÷å*èÿ ôó*êöèè äëÿ ïîñòðîå*èÿ ãð*ôèê*
//õ - ç**÷å*èå *ðãóìå*ò* äëÿ âû÷èñëå*èÿ ôó*êöèè
var
  y: real;
  i: integer;
  begin
    y := 0;
    for i := Np downto 1 do
      y := sin(x);
    Result := y;
end;
 
Function cosx(x: real): real;
//âû÷èñëå*èå ç**÷å*èÿ ôó*êöèè äëÿ ïîñòðîå*èÿ ãð*ôèê*
//õ - ç**÷å*èå *ðãóìå*ò* äëÿ âû÷èñëå*èÿ ôó*êöèè
var
  y: real;
  i: integer;
  begin
    y := 0;
    for i := Np downto 1 do
      y := sin(x);
    Result := y;
end;
 
procedure DrawGraph(a: real; b: real; c: TCanvas);
//ïîñòðîå*èå ãð*ôèê*
//* - *áñöèññ* **÷*ë* è*òåðâ*ë* ïîñòðîå*èÿ
//b - *áñöèññ* êî*ö* è*òåðâ*ë* ïîñòðîå*èÿ
//c - îáë*ñòü ðèñîâ**èÿ
var
  x, //*áñöèññ* ãð*ôèê*
  y, //ç**÷å*èå ôó*êöèè
  h: real; //ø*ã ìåæäó óçë*ìè ãð*ôèê*
  maxy, //ìè*èì*ëü*îå ç**÷å*èå ôó*êöèè ** è*òåðâ*ëå
  miny: real; //ì*êñèì*ëü*îå ç**÷å*èå ôó*êöèè ** è*òåðâ*ëå
  sx, //ì*ñøò*á*ûé êîýôôèöèå*ò ïî îñè Õ
  sy: real; //ì*ñøò*á*ûé êîýôôèöèå*ò ïî îñè Y
  xmid, ymid: integer; //òî÷ê* **÷*ë* êîîðäè**ò
procedure Grid(xmin, ymin, xmax, ymax: integer; a, b, miny, maxy: real);
//âûâîä êîîðäè**ò*îé ñåòêè
//xmin - *áñöèññ* êð*é*åé ëåâîé òî÷êè îáë*ñòè ïîñòðîå*èÿ
//ymin - îðäè**ò* êð*é*åé *èæ*åé òî÷êè îáë*ñòè ïîñòðîå*èÿ
//xmax - *áñöèññ* êð*é*åé ïð*âîé òî÷êè îáë*ñòè ïîñòðîå*èÿ
//ymax - îðäè**ò* êð*é*åé âåðõ*åé òî÷êè îáë*ñòè ïîñòðîå*èÿ
//* - *áñöèññ* **÷*ë* è*òåðâ*ë* ïîñòðîå*èÿ
//b - *áñöèññ* êî*ö* è*òåðâ*ë* ïîñòðîå*èÿ
//miny - ìè*èì*ëü*îå ç**÷å*èå ôó*êöèè ** è*òåðâ*ëå
//maxy - ì*êñèì*ëü*îå ç**÷å*èå ôó*êöèè ** è*òåðâ*ëå
var
  x, i: integer;
  h, h1: real;
begin
  c.Pen.Color := clSilver; //öâåò îñåé
  h := (xmax - xmin) / 10;
  h1 := (b - a) / 10;
  for i := 1 to 11 do //âåðòèê*ëü*ûå ëè*èè
    begin
      x := Round(xmin + (i - 1) * h);
      c.MoveTo(x, ymin);
      c.LineTo(x, ymax);
      if i <> 1 then
        c.TextOut(x+3, ymax-15, Format('%3.1f', [a + (i-1)*h1]));
    end;
  h := (ymax - ymin) / 10;
  h1 := (maxy - miny) / 10;
  for i := 1 to 11 do //ãîðèçî*ò*ëü*ûå ëè*èè
    begin
      x := Round(ymax - (i - 1) * h);
      c.MoveTo(xmin, x);
      c.LineTo(xmax, x);
      c.TextOut(3, x-15, Format('%3.1f', [miny + (i-1)*h1]));
    end;
end;
begin
  sx := (c.ClipRect.Right)/(b - a);
  h := 1 / sx;
  xmid := 0;
  ymid := c.ClipRect.Bottom - 1;
  x := a;
  maxy := sin(x);
  miny := maxy;
  while x<=b do
    begin
      y := sinx(x);
      if y<miny then miny := y;
      if y>maxy then maxy := y;
      x := x + h;
    end;
  c.Pen.Width := 1;
  sy := c.ClipRect.Bottom / (maxy - miny);
  c.Brush.Color := clWhite; //öâåò ôî**
  c.FillRect(Rect(0, 0, c.ClipRect.Right, c.ClipRect.Bottom));
  //îñè êîîðäè**ò
  Grid(0, 0, c.ClipRect.Right, c.ClipRect.Bottom, a, b, miny, maxy);
  c.Pen.Color := clBlack; //öâåò îñåé
  //îñü Õ
  c.MoveTo(0, ymid);
  c.LineTo(c.ClipRect.Right, ymid);
  //îñü Y
  c.MoveTo(xmid, 0);
  c.LineTo(xmid, c.ClipRect.Bottom);
  c.TextOut(c.ClipRect.Right-10, ymid - 15, 'X');
  c.TextOut(xmid+5, 10, 'Y');
  x := a;
  y := sin(x);
  c.Pen.Color := clRed; //öâåò ãð*ôèê*
  c.Pen.Width := 2;
  c.MoveTo(xmid+round(sx*(x-a)), ymid-round(sy*(y-miny)));
  while x<=b do
    begin
      y := sin(x);
      c.LineTo(xmid+round(sx*(x-a)), ymid-round(sy*(y-miny)));
      x := x + h;
    end;
   c.Refresh;
end;
 
procedure TForm1.cmdExit(Sender: TObject);
//âûõîä èç ïðîãð*ììû
begin
  Close;
end;
 
procedure TForm1.cmdDraw(Sender: TObject);
//ïîñòðîå*èå ãð*ôèê*
begin
  Image1.Picture.Bitmap.Width := Image1.Width;
  Image1.Picture.Bitmap.Height:=Image1.Height;
  DrawGraph(_start, _end, Image1.Canvas);
end;
 
procedure TForm1.FormResize(Sender: TObject);
begin
  cmdDraw(nil);
end;
 
procedure TForm1.aDataExecute(Sender: TObject);
//âûâîä îê** äëÿ ââîä* èñõîä*ûõ ä***ûõ
var
  i: integer;//ï*ð*ìåòð öèêë*
begin
  Form2.ShowModal;
  Np := Form2.SpinEdit1.Value;
  aDraw.Enabled := False;
  try
    _start := StrToFloat(Form2.Edit1.Text);
  except
    on EConvertError do // îøèáê* ïðåîáð*çîâ**èÿ ñòðîêè â ÷èñëî
      begin
        ShowMessage('Îøèáê* â ç**÷å*èè **÷*ë* è*òåðâ*ë*:' + #13 +
            '*åâåð*ûé ð*çäåëèòåëü öåëîé è äðîá*îé ÷*ñòåé' + #13 +
            'èëè *åäîïóñòèìûé ñèìâîë â ç*ïèñè ÷èñë*.');
        exit;
      end;
  end;
  try
    _end := StrToFloat(Form2.Edit2.Text);
  except
    on EConvertError do // îøèáê* ïðåîáð*çîâ**èÿ ñòðîêè â ÷èñëî
      begin
        ShowMessage('Îøèáê* â ç**÷å*èè êî*ö* è*òåðâ*ë*:' + #13 +
            '*åâåð*ûé ð*çäåëèòåëü öåëîé è äðîá*îé ÷*ñòåé' + #13 +
            'èëè *åäîïóñòèìûé ñèìâîë â ç*ïèñè ÷èñë*.');
        exit;
      end;
  end;
  if _end < _start then
    begin
      ShowMessage('Êî*å÷*îå ç**÷å*èå è*òåðâ*ë* äîëæ*î áûòü áîëüøå **÷*ëü*îãî!');
      exit;
    end;
  for i := Np downto 0 do
    begin
      try
        Ai[i] := StrToFloat(Form2.StringGrid1.Cells[Np - i, 1]);
      except
        on EConvertError do // îøèáê* ïðåîáð*çîâ**èÿ ñòðîêè â ÷èñëî
          begin
            ShowMessage('Îøèáê* â ç**÷å*èè êîýôôèöèå*ò*:' + #13 +
              '*åâåð*ûé ð*çäåëèòåëü öåëîé è äðîá*îé ÷*ñòåé' + #13 +
              'èëè *åäîïóñòèìûé ñèìâîë â ç*ïèñè ÷èñë*.');
            exit;
          end;
      end;
    end;
  aDraw.Enabled := True;  
end;
 
procedure TForm1.aAboutExecute(Sender: TObject);
//âûâîä êð*òêîé è*ôîðì*öèè î ïðîãð*ììå
begin
  Form3.ShowModal;
end;
end.
0
vilag
69 / 68 / 2
: 24.05.2012
: 146
31.05.2012, 02:48 #8

Delphi
1
public

Delphi
1
{ Public declarations }

Delphi
1
function f(x:real):real;

Delphi
1
2
3
4
5
6
7
8
9
function f(x:real):real;
  var y:real;
  begin
    case RadioDataGroup.itemindex of
    0:y:=sinx(x)
    1:y:=cosx(x)
   end;
   result:=y
end;

Delphi
1
2
3
4
5
6
7
8
9
function TForm1.f(x:real):real;
  var y:real;
  begin
    case RadioDataGroup.itemindex of
    0:y:=sinx(x)
    1:y:=cosx(x)
   end;
   result:=y
end;

- , .
0
barmatun
0 / 0 / 0
: 31.05.2012
: 6
31.05.2012, 02:52  [] #9
( ),

31
,

3
, , sinx cosx, ?
0
vilag
69 / 68 / 2
: 24.05.2012
: 146
31.05.2012, 02:53 #10
barmatun
, , sinx cosx, ?
.
0
barmatun
0 / 0 / 0
: 31.05.2012
: 6
31.05.2012, 03:01  [] #11
, 1:y:=cosx(x) missing operator or semicolon

4
, ;
0
31.05.2012, 03:01
MoreAnswers
37091 / 29110 / 5898
: 17.06.2006
: 43,301
31.05.2012, 03:01
! :

Switch case switch case - C++
! . . , while, switch...

HDD , - , -
- . ?

Turbo Pascal 7, ? (. , case ) - Turbo Pascal
case y of -12: y:=480; -11: y:=460; -10: y:=440; -9: y:=420; -8: y:=400; -7: y:=380; -6: y:=360; -5: y:=340; -4: y:=320;

Case switch - C++
: 1. , . 2. ...




:
11

- , ,
-
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
@Mail.ru