Bir Serideki Değeri Diğer Seride Arama
#include "stdio.h"
#include "stdlib.h" /* system("cls") , tolower(x) ve exit(0) fonksiyonları için */
#include "conio.h" /* getche() fonksiyonu icin */
void main()
{
int x[3]={17,42,90},y[20]={17,5,42,17,90,90,42,17,8,17,19,30,42,90,42,42,13,67,89,20};
int x1_count=0,x2_count=0,x3_count=0,i,j;
char secim;
printf ("n ----------------------------------");
printf ("n | |");
printf ("n | |");
printf ("n | |");
printf ("n ----------------------------------");
printf ("n | |");
printf ("n ----------------------------------");
printf ("nnnn **********");
printf ("n * 3.ODEV *");
printf ("n **********");
printf ("nnnnn ALI INAL");
printf ("n 200033028");
printf ("n End.Muh. 2C");
printf ("nnn ____Herhangi Bir Tusa Basiniz___");
secim=getche();
start:
system("cls");
printf ("n PROGRAM MENUSU");
printf ("n ----------------n");
printf ("n a) X dizisindeki degerlerin, Y dizisindeki tekrar miktarlarini buln");
printf ("n b) Cikisn");
printf ("nnSeciminiz (a/b)...");
soru:
secim=getche();
switch (tolower(secim))
{
case 'a':{
system("cls");
x1_count=0;
x2_count=0;
x3_count=0;
printf ("Seriler:n--------n x[3]={");
for (i=0;i<=2;i++)
{
printf("%d",x[i]);
if (i!=2) printf (",");
}
printf ("}ny[20]={");
for (i=0;i<=19;i++)
{
printf("%d",y[i]);
if (i!=19) printf (",");
}
printf ("}n");
for (i=0;i<=2;i++)
{
for (j=0;j<=19;j++)
{
if (x[i]==y[j])
{
switch(i)
{
case 0: x1_count++;break;
case 1: x2_count++;break;
case 2: x3_count++;break;
}
}
}
}
printf ("nFREKANSLAR ve HISTOGRAMLARI");
printf ("n-----------------------------------");
printf ("n%3d SAYISININ FREKANSI(%d) |",x[0],x1_count);
for (i=1;i<=x1_count;i++) printf("*");
printf ("n%3d SAYISININ FREKANSI(%d) |",x[1],x2_count);
for (i=1;i<=x2_count;i++) printf("*");
printf ("n%3d SAYISININ FREKANSI(%d) |",x[2],x3_count);
for (i=1;i<=x3_count;i++) printf("*");
printf ("nna) Ana Menuye Donus");
printf ("nb) Cikis");
printf ("nnSeciminiz (a/b)...");
soru2:
secim=getche();
switch (tolower(secim))
{
case 'a': goto start;
case 'b': {printf("nn");exit(0);}
default:{printf("nYanlis Secim! a veya b Giriniz..."); goto soru2;}
}
}
case 'b': {printf("nn");exit(0);}
default : {printf("nYanlis Secim! a veya b Giriniz..."); goto soru;}
}
}
C++ Builder - .....................................
İki Boyutlu Bir Dizi Hakkında
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
int t[4][5]={{7,13,310,427,204},{99,2,508,85,607},{28,44,807,797,308},{356,109,44,707,107}},i,j;
int eks,ekt,ebs,ebt,s=0;
double stndev=0,average;
char secim;
void main()
{
void maxmin();
void sumaver();
void standev();
void backquestion();
void tabloyaz();
void toplam();
void ortalama();
system ("cls");
printf ("n ----------------------------------");
printf ("n | ALGORITMALAR |");
printf ("n | ve |");
printf ("n | BILGISAYAR PROGRAMCILIGINA GIRIS |");
printf ("n ----------------------------------");
printf ("n | BIM 106/3 |");
printf ("n ----------------------------------");
printf ("nnnn **********");
printf ("n * 4.ODEV *");
printf ("n **********");
printf ("nnnnn ALI INAL");
printf ("n 200033028");
printf ("n End.Muh. 2C");
printf ("nnn ____Herhangi Bir Tusa Basiniz___");
secim=getch();
reprog:
system ("cls");
printf ("n KULLANILACAK DIZIn ---------------------------------n");
tabloyaz();
printf ("nn PROGRAM MENUSUn ---------------------------------");
printf ("n 1. En Buyukler/Kucukler");
printf ("n 2. Aritmetiksel Ortalama");
printf ("n 3. Standart Sapma");
printf ("n 4. Cikis");
printf ("nn ");
resoru:
printf ("Seciminiz...");
secim=getch();
switch (secim)
{
case '1': {
system ("cls");
tabloyaz();
printf ("n >>> Dizisinde En Buyuk, En Kucuk Analizi:n -----------------------------------------");
maxmin();
backquestion();
goto reprog;
break;}
case '2': {
system ("cls");
tabloyaz();
printf ("n >>> Dizisinde Aritmetiksel ");
sumaver();
printf ("n");
backquestion();
goto reprog;
break;}
case '3': {
system ("cls");
tabloyaz();
printf ("n >>> Dizisinde Standart ");
standev();
backquestion();
goto reprog;
break;}
case '4': {
printf ("nn");
exit(0);}
default: {
printf ("nYanlis Secim! "); goto resoru; break;}
}
}
void maxmin(void)
{
ebt=t[0][0];
ekt=t[0][0];
for (i=0;i<=3;i++)
{
eks=t[i][0];
ebs=t[i][0];
for (j=0;j<=4;j++)
{
if (t[i][j]<eks) eks=t[i][j];
if (t[i][j]>ebs) ebs=t[i][j];
if (ebs>ebt) ebt=ebs;
if (eks<ekt) ekt=eks;
}
printf ("n %d. Satirin En Buyugu= %4d En Kucugu=%4d",i,ebs,eks);
}
printf ("n");
for (i=0;i<=4;i++)
{
eks=t[0][i];
ebs=t[0][i];
for (j=0;j<=3;j++)
{
if (t[j][i]<eks) eks=t[j][i];
if (t[j][i]>ebs) ebs=t[j][i];
}
printf ("n %d. Sutunun En Buyugu= %4d En Kucugu=%4d",i,ebs,eks);
}
printf ("nn Tablonun En Buyugu= %4d Tablonun En Kucugu=%4d",ebt,ekt);
}
void toplam(void)
{
s=0;
for (i=0;i<=3;i++)
{
for (j=0;j<=4;j++)
{
s=s+t[i][j];
}
}
}
void sumaver(void)
{
toplam();
average=s/20.0;
printf ("Ortalama= %lf",average);
}
void ortalama(void)
{
toplam();
average=s/20.0;
}
void standev(void)
{
ortalama();
for (i=0;i<=3;i++) for (j=0;j<=4;j++) stndev=stndev+(pow(t[i][j]-average,2));
stndev=sqrt(stndev/20);
printf ("Sapma= %lfn",stndev);
}
void backquestion(void)
{
printf ("nn 1. Ana Menuye Donn 2. Cikisn");
resor:
printf (" Secminiz...");
secim=getch();
switch (secim)
{
case '1': break;
case '2': printf ("nn"); exit(0); break;
default: printf ("n Yanlis Secim!"); goto resor; break;
}
}
void tabloyaz(void)
{
printf ("n ");
for (i=0;i<=4;i++) printf (" [%d]",i);
printf("n");
for (i=0;i<=3;i++)
{
printf (" [%d]",i);
for (j=0;j<=4;j++) printf ("%5d",t[i][j]);
printf ("n");
}
}
C++ Builder - .....................................
Edit İçerisinden istenilen bilginin alınması
Delphi yeni başlayan biri olarak bu kod beni epey bir zorladı...
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
URL:string;
begin
URL:=Edit1.Text; // Değişkenimiz edit1'in text'idir
if Pos('http://', LowerCase(URL)) <> 0 then // Eğer http:// sonra büyük harf varsa küçük harfe çevir
System.Delete(URL, 1, 7); //baştaki http:// ifadesini sil
i := Pos('/', URL); // URL değişkeninin içerinde '/' işaretini ara
Edit2.Text := Copy(URL, 1, i); // / işaretinden sonraki karakteristiksel bilgiyi kopyala edit2 nin text ine at
Edit3.Text := 'C:PortixSoftDownload Managerdownload'+copy(URL, i+1, Length(URL) - i + 1);// / işaretinden sonraki karakteristiksel bilgiyi kopyala edit3 ün textine at...
end;
end.
Coder by Caylak...
Delphi - .....................................
Programı ftp den Güncelleme
Var
xDosyaUzunluk : LongInt;
function FTPDosyaAl( IdFTP : TIdFTP; SrcDosya, DesDosya:TFileName; Ftp, RemoteDir, Login, Pass : String ):Boolean;
begin // Uses IdFTP, IdFTPCommon
Result := False;
IdFtp.Host := Ftp;
IdFtp.Username := Login;
IdFtp.Password := Pass;
IdFtp.Passive := True;
IdFtp.Connect;
If IdFtp.Connected then
begin
IdFtp.ChangeDir(RemoteDir);
// Gauge'de kullanmak için
// Dosya Uzunluğunu grlobal bir değişkene atıyoruz...
xDosyaUzunluk := IdFtp.Size( SrcDosya );
Try
IdFtp.TransferType := ftBinary; // Uses IdFTPCommon
IdFtp.Get(SrcDosya, DesDosya, True);
Finally
Result := True;
end;
IdFtp.Quit;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
If FileExists(ExtractFilePath(Application.Exename) +'Guncelle.BAT')
then DeleteFile(ExtractFilePath(Application.Exename) +'Guncelle.BAT');
end;
procedure TForm1.Guncelle();
Var
FTPAdres,
KaynakDizin,
Name,
Pass,
KaynakDosya,
HedefDosya : String;
begin
// Bilerek bu örnek için 1 MB yer ayırarak açtığım FTP sunucu adresini veriyorum...
FTPAdres := 'emerkez.info';
KaynakDizin := '/programlar';
Name := 'delphi';
Pass := 'arman';
KaynakDosya := ExtractFileName(Application.Exename);
HedefDosya := ChangeFileExt( ExtractFilePath(Application.Exename) + KaynakDosya, '.BAK' );
HedefDosya := ChangeFileExt( ExtractFilePath(Application.Exename) + KaynakDosya, '.BAK' );
If FileExists(HedefDosya) AND ( MessageDlg('Hedef Dosya Mevcut, üzerine yazılsın mı ? '+#13'('+HedefDosya+')', mtInformation, [mbYes, mbCancel], 0) = mrCancel )
then EXIT
else DeleteFile(HedefDosya);
If FTPDosyaAl( IdFtp, KaynakDosya, HedefDosya, FTPAdres, KaynakDizin, Name, Pass )
then MessageDlg('Dosya Başarıyla Alındı'+#13#13
+ 'Şimdi program yeniden başlatılmak üzere kapatılacaktır....',
mtConfirmation, [mbOk], 0)
else MessageDlg('Dosya Alınamadı'+#13'('+KaynakDosya+')', mtError, [mbok], 0);
With TStringList.Create do begin
Add('@Echo Off' );
Add( Format('Copy %s %s', [ChangeFileExt(Application.ExeName,'.BAK'), Application.ExeName]) );
Add('DEL '+ChangeFileExt(Application.ExeName,'.BAK'));
Add( Application.ExeName );
SaveToFile( ExtractFilePath(Application.Exename)+'Guncelle.BAT' );
Free;
end;
Application.Terminate;
WinExec( PChar( ExtractFilePath(Application.Exename)+'Guncelle.BAT'), SW_Hide );
end;
procedure TForm1.IdFtpStatus(ASender: TObject; const AStatus: TIdStatus;
const AStatusText: string);
begin
StatusBar1.SimpleText := AStatusText;
end;
procedure TForm1.IdFtpWork(ASender: TObject; AWorkMode: TWorkMode;
AWorkCount: Integer);
begin
Gauge1.Progress := AWorkCount;
Application.ProcessMessages;
end;
procedure TForm1.IdFtpWorkBegin(ASender: TObject; AWorkMode: TWorkMode;
AWorkCountMax: Integer);
begin
Gauge1.MinValue := 0;
Gauge1.MaxValue := xDosyaUzunluk;
Gauge1.Progress := 0;
Gauge1.Visible := True;
end;
procedure TForm1.IdFtpWorkEnd(ASender: TObject; AWorkMode: TWorkMode);
begin
Gauge1.Progress := 0;
Gauge1.Visible := False;
end;
Kullanımı ise şu kadar basit
procedure TForm1.Button1Click(Sender: TObject);
begin
Guncelle();
end;
Delphi - .....................................
Windows Versiyon
type
TWindowsVersion = (wvUnknown, wvWin95, wvWin98, wvWinME, wvWinNT,
wvWin2k, wvWinXP, wvWin2k3, wvVista, wvSeven);
function GetWindowsVersion: TWindowsVersion;
begin
Result := wvUnknown;
if Win32Platform = VER_PLATFORM_WIN32_NT then
case Win32MajorVersion of
4: Result := wvWinNT;
5: case Win32MinorVersion of
0: Result := wvWin2k;
1: Result := wvWinXP;
2: Result := wvWin2k3;
end;
6: case Win32MinorVersion of
0: Result := wvVista;
7: case Win32MinorVersion of
0: Result := wvSeven;
end;
end
else
case Win32MinorVersion of
00: Result := wvWin95;
10: Result := wvWin98;
90: Result := wvWinME;
end;
end;
end;
// Kullanımı : if (GetWindowsVersion = wvWinXP) then ......
Delphi - .....................................
Çalışma Zamanında Buton Oluşturma
Procedure ButonClick(Sender:Tobject); // Private Tanim
{ Private declarations }
//
Public
End;
Var
Buton:Array of Tbutton; // Tanımlama
implementation
PROCEDURE BUTONOLUSTUR(Butonismi:String;Son:Integer);
Var
i:Integer;
begin
SetLength(Dizine,Son+1);
for i:=1 to son do
begin
Buton[i]:=TButton.Create(self);
buton[i].Parent :=Self;
with buton[i] do
begin
tag:=i;
Left :=550;
Top:=(basla*30);
Width :=20;
Height :=19;
Caption:='Butonismi '+ IntToStr(i-1);
Name :='Butonismi '+IntToStr(basla);
OnClick := ButonClick;
END ;
End; // Buton Sonu;
Procedure TForm1.ButonClick(Sender:Tobject);
Begin
ShowMessage('Yeni Butona Hoş Geldin');
End; // Onclick Olayı
Delphi - .....................................
dizi ile komponent kullanma
Selam arkadaşlar,
Aşağıdaki kod ile dinamik bileşen oluşturma ve kullanma görülmektedir.
***************************************************
merhaba,
Delphide çalışma anında forma nesne eklemek kolaydır.
Örneğin program başlarken ekrana 2 adet buton ekleyen kod şu şekildedir:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
procedure FormActivate(Sender: TObject);
procedure TusClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Tuslar:Array[1..10]of TButton;
implementation
{$R *.dfm}
procedure TForm1.FormActivate(Sender: TObject);
Begin
Tuslar[1]:=TButton.Create(Form1);
Tuslar[1].Setbounds(10,10,70,30); //Buton konumu
Tuslar[1].Parent:=Form1;
Tuslar[1].caption:='Yeni Buton1';
Tuslar[1].OnClick:=TusClick;
Tuslar[2]:=TButton.Create(Form1);
Tuslar[2].Setbounds(90,10,70,30); //Buton konumu
Tuslar[2].Parent:=Form1;
Tuslar[2].caption:='Yeni Buton2';
Tuslar[2].OnClick:=TusClick;
end;
procedure TForm1.TusClick(Sender: TObject);
begin
if sender=Tuslar[1] then Messagedlg('1 nolu butona
basıldı',mtinformation,[mbok],0);
if sender=Tuslar[2] then Messagedlg('2 nolu butona
basıldı',mtinformation,[mbok],0);
end;
end.
Delphi - .....................................
dizi'ye mevcut component'leri nasıl aktarabilrim..?
Dizi[1]:='1';
Dizi[2]:='1A';
Dizi[3]:='2';
Dizi[4]:='2A';
Dizi[5]:='3';
for i:=1 to 5 do
begin
if (dizi[i]) = ('2A')then
begin
//"2A"ya eşit diziyi buldum fakat
//Yukarıdaki Her Dizi Aslında Bir Buton component'i temsil ediyor
//buldugum diziye ait component'e nasıl kod yazabilirim
//bütün butonları if else yapısına sokmak saçma geldi
//buton sayısı 100 olursa if else çekilmez olur
//Şimdiden Teşekkürler..
Delphi - .....................................
Quick Reporda İstenilen Adres Satırlarını Çift Göstermek
Quick reporda bir listeleme prg yazıyordum bazı kişilerin açıklama bilgileri baya uzun olduğu için çift satır oluyor bazıları tek satırda kalıyordu delay bandını büyütüp iki satır yapıncada kısa olanlar cok çirkin bir görünüm alıyordu bu soru aşağıdaki gibi çözdüm
if Length(sender.AsString) > 50 then
begin
QuickRep1.Bands.DetailBand.Height:=72;
end else QuickRep1.Bands.DetailBand.Height:=32;
text:=sender.AsString;
burda qrdbtext için özellikleri :
Autosize := False
Boyutları çift satıra göre ayarlı
Delphi - .....................................
Delphi.net'te Hostname, Makine Adı, IP'yi alan Kod Örneği
system.net i unitin uses kısmına akleyiniz.
ben kodları butonun onclick ine yazdım. o kodu olduğu gibi yapıştıryorum.
procedure TWebForm1.Button1_Click(sender: System.Object; e: System.EventArgs);
var
ip:ipaddress;
begin
Response.Write(System.Net.Dns.GetHostByName('LocalHost').HostName);
Response.Write('<br>');
Response.Write(System.Environment.MachineName + ' ' + System.Net.Dns.GetHostName());
For ip In System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList do
Response.Write(ip);
end;
burda hostname i almanın iki yolu var. Makinenin ip sini ve makine adını alıyor.
Amacım system.net kutuphanesiile yapabilieceklerinizkonusundabir fikir vermekti.
Bu kutuphaneyi biraz gurcalamanızı oneririm...
Delphi.NET - .....................................
Momodaki Yazıyı Kopyalama İşlemi (Düzeltilmiş Hali)
Uses clipbrd;
memo1.SelectAll;
memo1.CopyToClipboard;
//Arkadaş eklemiş, bir kaç eksiklik vardı giderdim..
//eklediği için teşekkürler.
//kolay gelsin..
Delphi - .....................................
sihirli kareler makro
Sub SihirliKare()
Const BOYUT = 11
If BOYUT Mod 2 <> 1 Then
MsgBox "BOYUT tek sayı olmalı."
Exit Sub
End If
If BOYUT < 3 Then
MsgBox "BOYUT en az 3 olmalı."
Exit Sub
End If
If BOYUT > 255 Then
MsgBox "BOYUT Excel'in görüntüleyebileceğinden küçük olmalı. 3-255 arası bir tek sayı deneyin." & vbCr & vbCr & _
"(Yöntem teorik olarak sonsuza kadar herhangi bir tek sayı için uygulanabilir.)"
Exit Sub
End If
Dim YARIM As Long
YARIM = BOYUT 2
Dim i As Long, j As Long
Dim satir As Long, sutun As Long, sayi As Long
Sheets.Add 'Her şey yeni sayfada yapılıyor.
Cells.Select
With Selection
.ColumnWidth = 2.5
.RowHeight = 15
.Font.Size = 6
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
For i = 1 To BOYUT
For j = 1 To BOYUT
satir = BOYUT - j + i
sutun = j + i - 1
sayi = (i - 1) * BOYUT + j
If satir <= YARIM Then
Cells(satir + BOYUT - YARIM + 1, sutun - YARIM + 1) = sayi
ElseIf sutun <= YARIM Then
Cells(satir - YARIM + 1, sutun + BOYUT - YARIM + 1) = sayi
ElseIf satir > BOYUT + YARIM Then
Cells(satir - BOYUT - YARIM + 1, sutun - YARIM + 1) = sayi
ElseIf sutun > BOYUT + YARIM Then
Cells(satir - YARIM + 1, sutun - BOYUT - YARIM + 1) = sayi
Else
Cells(satir - YARIM + 1, sutun - YARIM + 1) = sayi
End If
Next
Next
Columns(1).Select
With Selection
.ColumnWidth = 12
.Font.Size = 8
End With
Cells(2, 1) = "BOYUT"
Cells(2, 1).Select
Selection.Font.Bold = True
Cells(3, 1) = "'" & BOYUT & "x" & BOYUT
Cells(5, 1) = "SAYILAR"
Cells(5, 1).Select
Selection.Font.Bold = True
Cells(6, 1) = "'1 - " & CDbl(BOYUT ^ 2)
Cells(8, 1) = "TOPLAMLAR"
Cells(8, 1).Select
Selection.Font.Bold = True
Cells(9, 1).Formula = "=SUM(B2:B" & BOYUT + 1 & ")"
Cells(1, 1).Select
End Sub
Delphi - .....................................