Recent

Author Topic: Program for search extremum  (Read 1690 times)

slava33

  • Newbie
  • Posts: 2
Program for search extremum
« on: June 02, 2019, 07:43:57 pm »
Help me make a program "Search for extremum" by the block diagram

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Program for search extremum
« Reply #1 on: June 02, 2019, 08:23:11 pm »
So how far did you get? Where is the code of your tries?

We help people with problems, but we don't write complete assignment code.

jamie

  • Hero Member
  • *****
  • Posts: 6091
Re: Program for search extremum
« Reply #2 on: June 02, 2019, 11:08:53 pm »
Lets see, it's Sunday here and we have a noob asking to get his home work done..

I bet the head is pounding from all the party activities over the weekend..

Good luck with your endeavor. :)
The only true wisdom is knowing you know nothing

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Program for search extremum
« Reply #3 on: June 02, 2019, 11:43:18 pm »
Lets see, it's Sunday here and we have a noob asking to get his home work done..

I bet the head is pounding from all the party activities over the weekend..

Good luck with your endeavor. :)

 :D
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

slava33

  • Newbie
  • Posts: 2
Re: Program for search extremum
« Reply #4 on: June 02, 2019, 11:49:19 pm »
Wow, I thought foreign forums would be more loyal. If you had seen how badly they teach in Russia... Everything has already been decided on the Russian forum and without further ado. The topic is closed.  :P

program Project1;
label
  a1,a2;
 
function f(xx: double):double;
begin
  f:= xx;
end;
 
 
var
  A,B,H,E,n: double;
  x,x1,x0: double;
  y,y1: double;
begin
  writeln('Введите значение аргумента А:');
  Readln(A);
  writeln('Введите значение аргумента B:');
  Readln(B);
  writeln('Введите значение аргумента E:');
  Readln(E);
  writeln('Введите значение аргумента n:');
  Readln(n);
  H:= (B - A)/n;
  a1:
  x:= A;
  a2:
  y:= f(x);
  x1:= x + H;
  y1:= f(x1);
  if y < y1 then
   begin
     x:= x + H;
     if x <= B - H  then
      goto a2
     else
      writeln('Экстремума нет:');
   end
  else
    begin
      if y1 - y <= E then
        begin
          x0:=(B - 2*H)/2;
          writeln('Результат вычислений:');
          writeln('x0 = ',x0:0:4,'; f(x) = ',f(x):0:4,'; E = ',E:0:4,'; H = ',H:0:4);
        end
      else
        begin
          H:= H/4;
          A:= x1 - 2*H;
          B:= x1;
          goto a1;
        end;
    end;
    Readln;
end.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Program for search extremum
« Reply #5 on: June 03, 2019, 12:44:39 am »
Wow, I thought foreign forums would be more loyal.

We are "loyal". What we are not is pansies. We don't come here to make your home-work (or whatever it is) for you, but to help you do it yourself. Why? Because otherwise you'll not learn.

If you had come with a failing program (even a bad one!), we would have probably teared it apart telling you where and, more important why it failed and showing you ways to make it better. Look around in this forum if you dont believe me.

Instead, you give us just a diagram and ask for the corresponding program. Come on! Coding from a flowchart is (still) a basic technique you should learn to master, much more with such an easy to translate chart.

The folks in the Russian forum haven't made you any favor.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

sash

  • Sr. Member
  • ****
  • Posts: 366
Re: Program for search extremum
« Reply #6 on: June 03, 2019, 09:54:53 am »
Wow, I thought foreign forums would be more loyal. If you had seen how badly they teach in Russia

Please just don't.

First, what I really see is that instead of getting learned you're trying to cheat with your homework.
Second, I live there. And I studied when there were no internet, not even modems, only printed books. And we had a "machine time schedule" for a program to be typed-in and run.

Guys, you have everything: GUI OSes, Google, broadband connection, smartphones, lots of examples and tutorials literally just for free.
And yet you want to copy-paste your basic homework instead of real learning. Why do you study computers if you don't really like it?
Lazarus 2.0.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

julkas

  • Guest
Re: Program for search extremum
« Reply #7 on: June 03, 2019, 01:32:19 pm »
Guys, you have everything: GUI OSes, Google, broadband connection, smartphones, lots of examples and tutorials literally just for free.

It's back side of the medal.

jamie

  • Hero Member
  • *****
  • Posts: 6091
Re: Program for search extremum
« Reply #8 on: June 03, 2019, 05:10:07 pm »
@Slava33

  You forgot a ABS function!

 I won't say where but its there!  :)
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018