Geri git   Van.GEN.TR Forum | Yerel Van Forumu > Bilgisayar > Programlama > Pascal

 
 
Konu Araçları Stil
Alt 27/05/07, 20:14   #4
salelltd
Albay
 
salelltd - ait Kullanıcı Resmi (Avatar)
 
Üyelik tarihi: May 2007
Bulunduğu yer: marsın en derin yeri
Yaş: 40
Mesajlar: 600
Tecrübe Puanı: 0 salelltd will become famous soon enough
Standart

65520 basamaklı sayılarla dört işlem(bölmeyi de siz yapın benim çok kafam karıştığı için bırakmıştım eskiden şimdi de canım hiç uğraşmak istemiyo)

uses crt;
const buyukN=65520;
type sayi=record s:array[1..buyukN] of char;n:word;end;
.....psayi=^sayi;
procedure birlestir(n:word;a,b: psayi;var c: psayi);{b'yi a'nın n'inci yerine ekle}
var i:word;
begin
..if (a=nil) or (b=nil) or ((n>a^.n) and (a^.n>1)) or (n=0) then exit;
..for i:=1 to n-1 do c^.s[i]:=a^.s[i];
..for i:=1 to b^.n do if i+n>buyukN then begin c^.n:=i+n-1;exit;end else c^.s[i+n-1]:=b^.s[i];
..for i:=n to a^.n do if i+b^.n>buyukN then begin c^.n:=i+b^.n-1;exit;end else c^.s[i+b^.n]:=a^.s[i];
..c^.n:=a^.n+b^.n;
end;
procedure sil(a: psayi;n,k:word;var b: psayi);{a'nın n'inci harfinden başlayarak k harf sil}
var i:word;
begin
..if a=nil then exit;
..if n>a^.n then begin b^.n:=0;exit;end;
..for i:=1 to n-1 do b^.s[i]:=a^.s[i];
..if n+k>a^.n then begin b^.n:=n-1;exit;end;
..for i:=n+k to a^.n do b^.s[i-k]:=a^.s[i];
..b^.n:=a^.n-k;
end;
function buyuk(a,b: psayi):shortint;{-1:hata ,0:eşit, 1:a büyük, 2:b büyük}
var i:byte;bul,n:boolean;
begin
..if (a=nil) or (b=nil) then begin buyuk:=-1;exit;end;n:=false;
..if (a^.s[1]='-') and (b^.s[1]='-') then n:=true;
..if (a^.s[1]='-') and (b^.s[1]<>'-') then buyuk:=2 else if (a^.s[1]<>'-') and (b^.s[1]='-') then buyuk:=1 else
..begin
....bul:=false;
....if a^.n>b^.n then begin bul:=true;if n then buyuk:=2 else buyuk:=1;end else
....if b^.n>a^.n then begin bul:=true;if n then buyuk:=1 else buyuk:=2;end else
....begin
......for i:=1 to a^.n do
......if ord(a^.s[i])>ord(b^.s[i]) then begin if n then buyuk:=2 else buyuk:=1;bul:=true;break;end else
......if ord(b^.s[i])>ord(a^.s[i]) then begin if n then buyuk:=1 else buyuk:=2;bul:=true;break;end;
......if not bul then buyuk:=0;
....end;
..end;
end;
procedure carpim(a,b: psayi;var carpilan: psayi);forward;
function katbul(a,b: psayi):char;
var i:byte;k,l: psayi;bs:shortint;
begin
..new(k);new(l);
..for i:=1 to 10 do
..begin
....k^.n:=1;k^.s[1]:=chr(i+48);carpim(k,a,l);bs:=buyuk(l,b);if (bs=1) or (bs=0) then break;
..end;
..katbul:=chr(i+47);
..dispose(k);dispose(l);
end;
procedure toplam(a,b: psayi;var toplanan: psayi);
var tmp,tmp2: psayi;an,bn,x:longint;c:byte;af:boolean;y:word;
begin
..af:=false;new(tmp);new(tmp2);new(toplanan);topla nan^.n:=0;
..an:=a^.n;bn:=b^.n;x:=an-bn;
..if x<>0 then
..begin
....tmp^.n:=abs(x);for y:=1 to abs(x) do tmp^.s[y]:='0';
....if x>0 then begin birlestir(1,tmp,b,tmp2);b^.s:=tmp2^.s;b^.n:=tmp2^. n;end else
....if x<0 then begin birlestir(1,tmp,a,tmp2);a^.s:=tmp2^.s;a^.n:=tmp2^. n;end;
..end;
..for x:=a^.n downto 1 do
..begin
....if not ((ord(a^.s[x])-48 in [0..9]) and (ord(b^.s[x])-48 in [0..9])) then break;
....c:=ord(a^.s[x])-48+ord(b^.s[x])-48+ord(af);af:=false;
....if c>9 then begin c:=c-10;af:=true;end;
....tmp2^.n:=1;tmp2^.s[1]:=chr(c+48);
....birlestir(1,toplanan,tmp2,tmp);toplanan^.s:=tm p^.s;toplanan^.n:=tmp^.n;
..end;
..if af then
..begin
....tmp2^.n:=1;tmp2^.s[1]:='1';birlestir(1,toplanan,tmp2,tmp);toplanan^.s:= tmp^.s;toplanan^.n:=tmp^.n;
..end;
..dispose(tmp);dispose(tmp2);
end;
procedure carpim(a,b: psayi;var carpilan: psayi);
var s,tmp,tmp2: psayi;x,y,z,k,l:byte;
begin
..new(carpilan);new(s);new(tmp);new(tmp2);
..carpilan^.s[1]:='0';carpilan^.n:=1;
..if a^.n<b^.n then
..begin
....s^.n:=a^.n;s^.s:=a^.s;
....a^.n:=b^.n;a^.s:=b^.s;
....b^.n:=s^.n;b^.s:=s^.s;
..end;
..l:=0;
..for x:=b^.n downto 1 do
..begin
....s^.n:=0;k:=0;
....for y:=a^.n downto 1 do
....begin
......if not ((ord(a^.s[y])-48 in [0..9]) and (ord(b^.s[x])-48 in [0..9])) then break;
......z:=(ord(b^.s[x])-48)*(ord(a^.s[y])-48)+k;k:=0;if z>9 then k:=z div 10;
......tmp^.n:=1;tmp^.s[1]:=chr(z mod 10+48);
......birlestir(1,s,tmp,tmp2);s^.n:=tmp2^.n;s^.s:= tmp2^.s;
....end;
....if k>0 then
....begin
......tmp^.n:=1;tmp^.s[1]:=chr(k+48);
......birlestir(1,s,tmp,tmp2);s^.n:=tmp2^.n;s^.s:= tmp2^.s;
....end;
....tmp^.n:=x+l-1;for y:=1 to x+l-1 do tmp^.s[y]:='0';
....birlestir(1,s,tmp,tmp2);s^.n:=tmp2^.n;s^.s:=tm p2^.s;
....toplam(carpilan,s,tmp2);carpilan^.n:=tmp2^.n;c arpilan^.s:=tmp2^.s;
..end;
..while carpilan^.s[1]='0' do
..begin
....sil(carpilan,1,1,tmp);carpilan^.n:=tmp^.n;carp ilan^.s:=tmp^.s;if carpilan^.n=0 then break;
..end;
..dispose(tmp);dispose(tmp2);dispose(s);
end;
procedure yaz(p: psayi);
var i:word;
begin
..for i:=1 to p^.n do write(p^.s[i]);
end;
procedure oku(var p: psayi);
var i:word;c:char;
begin
..i:=1;new(p);
..repeat
....c:=readkey;
....case c of
......'0'..'9':begin
.................p^.s[i]:=c;i:=i+1;gotoxy(1,wherey);p^.n:=i-1;yaz(p);
.............. end;
......#8:if i>1 then
.........begin
...........i:=i-1;gotoxy(1,wherey);p^.n:=i-1;yaz(p);mem[$B800: (wherex-1)*2+(wherey-1)*160]:=32;
........ end;
......#27:halt;
....end;
..until (i>buyukN) or (c=#13);
..p^.n:=i-1;writeln;
end;
var a,b,c: psayi;
begin
..writeln('iki sayı giriniz:');oku(a);oku(b);
..writeln('çarpımı:');carpim(a,b,c);
{..writeln('Birleşimi:');birlestir(2,a,b,c);}
{..writeln('Toplamı:');toplam(a,b,c);}
..yaz(c);readln;
..dispose(a);dispose(b);dispose(c);
end.

Konu salelltd tarafından (27/05/07 Saat 20:45 ) değiştirilmiştir..
salelltd isimli Üye şimdilik offline konumundadır   Alıntı ile Cevapla
Konu Sayısı: 3
 


Konuyu Toplam 1 Üye okuyor. (0 Kayıtlı üye ve 1 Misafir)
 

Yetkileriniz
Yeni Mesaj yazma yetkiniz Aktif değil dir.
Mesajlara Cevap verme yetkiniz aktif değil dir.
Eklenti ekleme yetkiniz Aktif değil dir.
Kendi Mesajınızı değiştirme yetkiniz Aktif değildir dir.

BB code is Açık
Smileler Açık
[IMG] Kodları Açık
HTML-KodlarıKapalı
Gitmek istediğiniz klasörü seçiniz


Bütün Zaman Ayarları WEZ +3 olarak düzenlenmiştir. Şu Anki Saat: 14:10 .


Powered by vBulletin
Copyright © 2000-2007 Jelsoft Enterprises Limited.
Sitemap
6, 5, 3, 7, 8, 9, 10, 11, 12, 13, 14, 15, 113, 16, 17, 18, 19, 81, 20, 27, 22, 23, 24, 25, 26, 48, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 43, 136, 40, 58, 45, 42, 44, 46, 47, 53, 54, 55, 56, 57, 59, 60, 70, 61, 62, 63, 64, 65, 66, 68, 69, 71, 72, 74, 75, 76, 77, 78, 79, 80, 82, 83, 96, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 98, 97, 100, 101, 102, 103, 106, 104, 105, 112, 109, 108, 107, 110, 111, 114, 115, 118, 116, 117, 119, 148, 154, 124, 165, 122, 120, 123, 121, 150, 153, 125, 128, 129, 131, 132, 133, 134, 135, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 151, 149, 202, 175, 164, 152, 167, 155, 156, 157, 158, 159, 160, 161, 162, 163, 195, 169, 166, 168, 170, 171, 172, 199, 174, 173, 196, 200, 176, 177, 180, 178, 179, 182, 189, 187, 184, 186, 191, 192, 193, 194, 197, 198, 201, 203, 229, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 236, 231, 232, 233, 234, 235, 237, 240, 239, 241, 243, 242, 244,