Make the programs for printable of 10 numbers whos delimetery to positive and negative
Delphi & Pascal (česká wiki)
Category: Homework in Pascal
Program: Kladne.pas
File exe: Kladne.exe
flow: Kladne.gif
Program: Kladne.pas
File exe: Kladne.exe
flow: Kladne.gif
Make the programs for printable of 10 numbers whos delimetery to positive and negative.
{ KLADNE.PAS Copyright (c) TrSek alias Zdeno Sekerak } { Odladte program pre vypocet a tlac hodnot, ak mame 10 nacitanych } { cisel, ktore treba rozdelit na kladne a zaporne do dvoch stlpcov } { } { Datum:04.02.2004 http://www.trsek.com } program kladne_zaporne; uses crt; var kl:array[1..10] of real; zap:array[1..10] of real; poc_kl:integer; poc_zap:integer; cis:real; i:integer; begin ClrScr; poc_kl := 0; poc_zap := 0; WriteLn('Program rozdeli zadane cisla na kladne a zaporne.'); WriteLn('Zadaj pocet 10 cisel.'); { nacita cisla } for i:=1 to 10 do begin Write('Zadaj cislo[',i,']='); ReadLn(cis); { ak je zaporne ulozi do zap[] } if( cis < 0 ) then begin poc_zap := poc_zap + 1; zap[ poc_zap ] := cis; end else { ak je kladen ulozi do kl[] } begin poc_kl := poc_kl + 1; kl[ poc_kl ] := cis; end; end; WriteLn; WriteLn('Cisla rozdelene na kladne a zaporne'); WriteLn; WriteLn('| Kladne | Zaporne|'); WriteLn('-------------------'); { budem vypisovat } for i:=1 to 10 do begin { su obe stlpce } if(( i <= poc_kl ) and (i <= poc_zap ))then WriteLn('|', kl[i]:8:3, '|', zap[i]:8:3, '|'); { je len lavy stlpec } if(( i <= poc_kl ) and (i > poc_zap ))then WriteLn('|', kl[i]:8:3, '| |'); { je len pravy stlpec } if(( i > poc_kl ) and (i <= poc_zap ))then WriteLn('| |', zap[i]:8:3, '|'); end; WriteLn('-------------------'); ReadLn; end.