Funkcje odczytu i zapisu. Klasyfikacja typów danych


Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 47

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 49

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 47

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 49

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 47

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 49

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 47

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 49

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 47

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 49

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 47

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 49

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 47

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 49

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 47

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 49

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 47

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 49

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 47

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 49

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 47

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 49

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 47

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 49

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 47

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 49

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 47

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 49

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 47

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 49

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 47

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/platne/serwer318421/public_html/zeszyt.jedlikowski.com/wp-content/plugins/latex/latex.php on line 49
write() { wyświetla na ekranie wartość przekazaną do funkcji jako argument w postaci łańcucha znakowego }
writeln() { wyświetla na ekranie wartość przekazaną do funkcji jako argument w postaci łańcucha znakowego i ustawia kursor w kolejnej linii }
read() { oczekuje na wpisanie z klawiatury znaków}
readln() { oczekuje na wpisanie z klawiatury znaków i ustawia kursor w kolejnej linii }
readln { funkcja bezwarunkowa, powoduje oczekiwanie na naciśnięcie klawisza Enter}

Typy danych

  • Tryb wyliczeniowy
  • Tryb okrojony - służy do ograniczenia zakresów wartości dowolnego ciągu znaków
  • Typy całkowite
    • SHORTINT: -128 .. 127. Zajmuje 1 bajt.
    • BYTE: 0 .. 255. Zajmuje 1 bajt.
    • INTEGER: -32768..32767. Zajmuje 2 bajty.
    • WORD: 0 .. 65535. Zajmuje 2 bajty.
    • LONGINT: -2 147 483 648 .. 2 147 483 647. Zajmuje 4 bajty.
  • Typy rzeczywiste
    • REAL: do . Zajmuje 6 bajtów, mantysa 11 lub 12
    • SINGLE: do . Zajmuje 4 bajty, mantysa 7 lub 8
    • DOUBLE: do . Zajmuje 8 bajtów, mantysa 15 lub 16
    • EXTENED: do . Zajmuje 10 bajtów, mantysa 19 lub 20
  • Typ logiczny
    • BOOLEANtrue albo false
  • Typ łańcuchowy
    • STRING[byte rozmiar]. Brak wartości rozmiar powoduje przyjęcie domyślne wartości rozmiar:=255.

Zadanie 1. Wczytaj 2 liczby całkowite. Wypisz ich sumę, różnicę, iloczyn i iloraz.

program dzialania;
var a,b: real;

begin
        write('Pierwsza liczba: ');
        readln(a);
        write('Druga liczba: ');
        readln(b);

        writeln(a:12:3,' + ',b:12:3,' = ',a+b:12:3);
        writeln(a:12:3,' - ',b:12:3,' = ',a-b:12:3);
        if (a<>0) and (b<>0) then
                begin
                        writeln(a:12:3,' * ',b:12:3,' = ',a*b:12:3);
                        writeln(a:12:3,' / ',b:12:3,' = ',a/b:12:3);
                end
        else
                begin
                        writeln('Nie można wykonać mnożenia i dzielenia.');
                end;

        readln;
end.

Zadanie 2. Zmodyfikuj.

program dzialania;

uses crt;

var
	a,b: LongInt;
	liczba: byte;

begin
	write('Pierwsza liczba: ');
	readln(a);
	write('Druga liczba: ');
	readln(b);

	writeln('Wybierz dzialanie:');
	writeln('1: dodawanie');
	writeln('2: odejmowanie');
	writeln('3: mnozenie');
	writeln('4: dzielenie');
	writeln('5: modulo');

	read(liczba);

	CASE liczba OF
		1 : writeln(a,' + ',b,' = ',a+b);
		2 : writeln(a,' - ',b,' = ',a-b);
		3 : begin
				if ((a<>0) and (b<>0)) then
					writeln(a,' * ',b,' = ',a+b)
				else
					writeln('Nie mozna wykonac tej operacji.');
			end;
		4 : begin
				if ((a<>0) and (b<>0)) then
					writeln(a,' / ',b,' = ',a/b)
				else
					writeln('Nie mozna wykonac tej operacji.');
			end;
		5 : writeln(a,' % ',b,' = ',a mod b);
	end;

	delay(2000);
end.

 

Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany. Wymagane pola są oznaczone *

Witryna wykorzystuje Akismet, aby ograniczyć spam. Dowiedz się więcej jak przetwarzane są dane komentarzy.