Welcome to DiziEvi Film Dizi Dünyasının Yeni Adresi DiziEvi.NeT

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

Soru sor

Sorularınız var ise sorup cevaplayabilirsiniz.

Cevap

Sorularınızı Uzman Ekibimiz Tarafından Cevaplarınızı Alın

İletişime Geçin

Uzmanlarımız Sorularınızı Cevaplamaya Hazır

Örnek Kodlar.... Source Codes....

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Örnek Kodlar.... Source Codes....

vb code

'Web-Formlarini otomatik doldurma
'Gerekli araclar
'Control CommandButton: cmdFill
'Control CommandButton: cmdSend
'Control TextBox: txtTime
'Control TextBox: txtDate
'Control TextBox: txtName
'Control WebBrowser: wbrWebBrowser
'
'Yazar: Ulas Isci


Option Explicit

Private Sub cmdFill_Click()
'sayfada daha cok formlar varsa bunlar document.forms(1) ve (2) diye devam belirtilir.


With wbrWebBrowser
.Document.Forms(0).field1.Value = txtName.Text
.Document.Forms(0).field2.Value = txtTime.Text
.Document.Forms(0).field3.Value = txtDate.Text
.Document.Forms(0).textfeld.Value = lblText.Caption
End With
End Sub

Private Sub cmdSend_Click()
'formdaki klick funksiyonu
wbrWebBrowser.Document.Forms(0).submit.Click
End Sub

Private Sub Form_Load()
wbrWebBrowser.Navigate App.Path & "\form.htm"
txtName.Text = "Anonymus"
txtTime.Text = Time
txtDate.Text = Date

lblText.Caption = "test test test"
End Sub
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
vb code
30 gün deneme süresi

Private Sub form_load()

Dim enddate As Date
enddate = GetSetting("Demo", "Demo", "EndDate", "01.01.89")
'EndDate = "01.01.89" ise enddate belirleniyor.
If enddate = "01.01.89" Then
enddate = Date
enddate = enddate + 30 '30 Gün toplaniyor
SaveSetting "Demo", "Demo", "EndDate", enddate 'EndDate kayitlaniyor
End If

If Date > enddate Then MsgBox "Demo Süresi bitmistir."
End Sub
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
c'de basit bir animasyon

Bu kodları "animasyn.cpp" olarak kaydedin. Daha sonra egavga.bgi dosyasını C programının kurulu olduğu klasörde arattırıp bulun ve "animasyn.cpp" dosyasının bulunduğu klasörün içine kopyalayın. "animasyn.cpp" dosyasını C'de derleyin. C'de programı debug yapmadan önce Options\Linker\Libraries yoluyla Çıkan Pencerede Graphics Library seçeneğini aktif hale getirin. Sonra Programı Çalıştırabilirsiniz.


#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>

int main(void)
{
/* request auto detection*/
int gdriver=DETECT, gmode, errorcode;
int midx, midy, i, a, s, c, k;

/*initialize graphics and local variables*/
initgraph(&gdriver, &gmode, "");

/* read result of initialization*/
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred*/
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code*/
}

midx = getmaxx()-640;
midy = getmaxy()-480;

for(k=0;k<=640;k=k+10)
{
for(s=0;s<=640;s=s+10)
{
for(i=0;i<=10;i++)
{
for(a=0;a<=10;a++)
{
/*printf("%d,%d,%d",midx+a+k,midy+s+i,c);*/
putpixel(midx+a+k,midy+s+i,c);
}
}
c++;
}
}
for(k=0;k<=640;k=k+10)
{
for(s=0;s<=640;s=s+10)
{
for(i=0;i<=10;i++)
{
for(a=0;a<=10;a++)
{
putpixel(midx+a+k,midy+s+i,0);
}
}
c++;
}
}
/* clean up */
getch();
closegraph();
return 0;
}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
pascalda lise 2lere yönelik not hesaplama
yazar cihan büyükburç

uses crt;
type
st10 = string[10];
const
ders:array[1..12] of string[10]=('Edebiyat','Din kültürü','Ingilizce',
'Milli güvenlik','Matematik','Fizik',
'Isletim sistemleri','Atelye',
'Programlama','Paket programlama',
'Isletme bilgisi','Geometri');
max=10;
var
isim : array[1..max] of string[20];
n : array[1..max,1..5,1..3]of byte;
i,j,e : byte;
tus : char;
cizgi : string[80];
satir : byte;

procedure cerceve(x1,x2,y1,y2:byte);
var
k : byte; 4
begin
gotoxy(x1,y1);write(#201);
for k:=x1+1 to x2-1 do write(#205);
write(#187);
for k:=y1+1 to y2-1 do begin
gotoxy(x1,k);write(#186);
gotoxy(x2,k);write(#186);
end;
gotoxy(x1,y2);write(#200);
for k:=x1+1 to x2-1 do write(#205);
write(#188);
end;
procedure ilkekran;
begin
clrscr;
cerceve(1,1,80,24);
cerceve(3,2,78,4);
cerceve(3,5,20,20);
cerceve(22,5,60,7);
cerceve(22,8,60,23);
cerceve(62,5,78,20);
cerceve(3,21,20,23);
cerceve(62,21,78,23);
gotoxy(25,3);write('PROGRAMI HAZIRLAYAN : CIHAN BšYšKBUR€ ');
end;
procedure BilgiGirisi;
begin
clrscr;
if e < max then
begin
e:=e+1;
write(E,'. ™grenci Adi....:');readln(isim[E]);
if isim[e]="then
begin
e:=e-1;exit;
end;
for j:=1 to 12 do begin
write(Ders[j],'.1. Notu giriniz......:');readln(N[E,j,1]);
write(Ders[j],'.2. Notu giriniz......:');readln(N[E,j,2]);
write(Ders[j],'.3. Notu giriniz......:');readln(N[E,j,3]);
writeln;
end;
end
else
begin
gotoxy(20,10);write('Daha Fazla Bilgi Girilemez... ');
tus:=readkey;
end;
end;
function ort:real;
begin
ort:=(n[i,j,1]+n[i,j,2]+n[i,j,3])/3;
end;
function sonuc:st10;
begin
if ort<45 then sonuc:='KALDI' else sonuc:='GEÇTI';
end;
procedure yaz;begin
clrscr;
writeln('(',i,') ™grenci Adi.....:',isim);
writeln;
writeln('Ders adi',' ':20,'Not-1',' ' :12,'Not-2',' ':12,
'Not-3',' ':12,'ort',' ':12,'sonuc');
writeln(cizgi);
for j:=1 to 12 do begin
gotoxy(1,j+4);write(Ders[j]);
gotoxy(30,j+4);write(n[i,j,1]:2);
gotoxy(40,j+4);write(n[i,j,2]:2);
gotoxy(50,j+4);write(n[i,j,3]:2);
gotoxy(60,j+4);write(ort:3:0);
gotoxy(68,j+4);write(sonuc);
end;
end;
procedure tumliste;
begin
for i:=1 to e do begin
begin
yaz;
tus:=readkey;
end;
gotoxy(25,20);write('Listelenecek Kayitlar Bitti...');
tus:=readkey;
end;
end;
procedure bilgiarama;
var
ara : string[20];
begin
repeat
clrscr;
cerceve(20,9,60,11);
gotoxy(22,10);write('Isim...:');readln(ara);
if ara=' ' then exit;
for i:=1 to e do begin yaz;
gotoxy(10,20);write('Aradiginiz Bu mu ?[E/H]');
repeat
tus:=upcase(readkey);
until tus in ['E','H'];
if tus='E' then exit;
end;

gotoxy(10,30);write('Aradiginiz Kayit Yok....');
tus:=readkey;
until 1=2;
end;
procedure baslik;
var
k : byte;
begin
clrscr;
write('Ogrenci Adi',":22);
for k:=1 to 12 do write(Ders[k]:10);
writeln(' ort ');
writeln(cizgi);
satir:=2;
end;

procedure Dersortalama;
var
Gnot : integer;
Gn : byte;
begin
baslik;
for i:=1 to E do begin
satir:=satir+1;
gotoxy(1,satir);write(isim);
gnot:=0;
for j:=1 to 12 do begin
Gn:=round(ort);
gotoxy(15+j*10,satir);write(Gn:3);
gnot:=Gnot+Gn;
end;
gotoxy(75,satir);write(Gnot/5:3:0);
if satir=20 then
begin
gotoxy(20,25);
write('Diger Sayfa i‡inçBir Tusa Basiniz..');
tus:=Readkey;
baslik;
end;
end;
end;
procedure Baslik2;
begin
clrscr;
write('Ogrenci Adi..',":22);
writeln('Genel Ortalama');
writeln(Copy(cizgi,1,40));
satir:=2;
end;
procedure GenelOrtalama;
var
Gnot,SinifT:integer;
Gn :byte;
begin
baslik2;sinifT:=0;
for i:=1 to E do
begin
satir:=satir+1;
gotoxy(1,satir);write(isim);
Gnot:=0;
for j:=1 to 12 do Gnot:=Gnot+Round(ort);
Gn:=Round(Gnot/12);
SinifT:=SinifT+Gn;
Gotoxy(35,Satir);write(Gn:3);
if satir=20 then
begin
gotoxy(20,25);
write('Diger Sayfa i‡in Bir Tusa Basiniz..');
tus:=readkey;
baslik2;
end;
end;
writeln;writeln;
writeln('Sinif Not Ortalama=','SinifT/E:5:');
gotoxy(15,25);
write('Listelenecek Kayitlar Bitti.Bir Tusa Basiniz..');
tus:=readkey;
end;
{ Ana Program }
begin
e:=0;
fillchar(cizgi,80,205);
cizgi[0]:=#79;
repeat
ilkekran;
gotoxy(30,10);write(' 1- Bilgi Girisi ');
gotoxy(30,12);write(' 2- Tum Liste ');
gotoxy(30,14);write(' 3- Bilgi Arama ');
gotoxy(30,16);write(' 4- Ders Ortalamalari ');
gotoxy(30,18);write(' 5- Genel Ortalamalari ');
gotoxy(30,20);write(' 6- Cikis ');
gotoxy(30,22);write(' Se‡iminiz[1..6]');
gotoxy(30,24);write(':) ˜yi gnlerde kullann :)');
repeat
tus := readkey;
until tus in ['1'..'6'];
case tus of
'1' :BilgiGirisi;
'2' :TumListe;
'3' :BilgiArama;
'4' :Dersortalama;
'5' :GenelOrtalama;
'6' :Halt;
end; { case }
until 1=2;
end.
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
3(iki dolduran,bir boşaltan) musluk için kaç saatte bir açilip kapanacak ve tankin kapasitesine göre dolup dolamdiğini veren zaman sayaçli bir program.
/* Musluk Programı*/
#include <stdio.h>
int main (void)
{
int v,initial,pipe_a,pipe_b,pipe_drain,cycle_a,cycle_b ,cycle_drain,level,hour,x_a,x_b,x_drain;
printf("TANK SIMULATION
");
printf("Enter capacity of tank(lts.):");
scanf("%d",&v);
printf("Enter initial level of tank(lts.):");
scanf("%d",&initial);
printf("Enter rate of pipe A:(lts./hr.):");
scanf("%d",&pipe_a);
printf("Enter rate of pipe B:(lts./hr.):");
scanf("%d",&pipe_b);
printf("Enter rate of drain:(lts./hr.):");
scanf("%d",&pipe_drain);
printf("Open and closed cycle of pipe A(hrs.):");
scanf("%d",&cycle_a);
printf("Open and closed cycle of pipe B(hrs.):");
scanf("%d",&cycle_b);
printf("Open and closed cycle of drain(hrs.):");
scanf("%d",&cycle_drain);
printf("Hour Pipe A Pipe B Drain Level
");
printf("%2d%9d%9d%9d%9d
",0,0,0,0,initial);
level=initial;
for(hour=1;level<=v&&level>0;hour=hour+1)
{ if(((hour-1)/cycle_a)%2==0)
x_a=pipe_a;
else
x_a=0;
if(((hour-1)/cycle_b)%2==0)
x_b=pipe_b;
else
x_b=0;
if(((hour-1)/cycle_drain)%2==0)
x_drain=pipe_drain;
else
x_drain=0;
level=level+x_a+x_b-x_drain;
printf("%2d%9d%9d%9d%9d
",hour,x_a,x_b,x_drain,level);
}//finished the for statement......
if(level>=v)
printf("Tank is full!! Hours=%d",hour-1);
//hour'u bir azaltmamin sebebi for statement'ta bir arttirip sonra kontrol etmesi(hour=hour+1)
if(level<=0)
printf("Tank is empty!! Hours=%d",hour-1);
//hour'u bir azaltmamin sebebi for statement'ta bir arttirip sonra kontrol etmesi(hour=hour+1)
getchar();
getchar();
getchar();
return(0);
}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
c Password
yazan Cem KOÇ


#include <conio.h>
#include <ctype.h>
#include <string.h>

int main(void)
{
int i=0;
int curr_x = 16;
char temp = '';
char pass[20] = "duke"; // this is the valid password
char string[20] = { '' };

/* clear the screen */
clrscr(); //comment it if not using borland or turbo compiler

/* Prompt the user for input */
textcolor( WHITE ); //this command might not work on some compilers
cprintf("Enter Password: ");


while( temp != ' ' )
{
/* read the input */
temp = getch();

if( isprint( temp ) != 0 )
string = temp;

/*prints stars instead of actual characters*/
if( iscntrl( temp ) == 0 )
{
textcolor( WHITE ); //this command might not work on some compilers
cprintf( "*" );
curr_x++;
}

if( temp == '' )
{
gotoxy( curr_x, 1 );
cprintf( " " );
gotoxy( curr_x, 1 );
string[i-1] = '';
i--;
curr_x--;
}
else i++;
}

if( strcmp( string, pass ) == 0 )
{
textcolor( LIGHTBLUE ); //this command might not work on some compilers
cprintf( " ACCESS !!!" );
}
else
{
textcolor( LIGHTRED ); //this command might not work on some compilers
cprintf( " ACCESS DENIED !!!" );
}

/* display what was read */
textcolor( WHITE ); //this command might not work on some compilers
cprintf(" The password entered is: %s", string);
getch();
return 0;
}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
C dilinde hazırlanmış bu program ile fibonacci serileri recursive fonksyion kullanarak hesaplanmıştır.
# include <stdio.h>

double fibonacci (int f)
{
double ara1 , ara2;
if (f<=1)
return f;
else
{
ara1 = fibonacci( (f-1) ) ;
ara2 = fibonacci( (f-2) ) ;
return ( ara1 + ara2);
}
}


void main()
{
double sonuc;
int sayi;
printf ("Fibonacci bulunacak sayıyı giriniz :");
scanf("%d",&sayi);
sonuc = fibonacci (sayi);
printf ("%lf",sonuc);
}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
/*C0dER:: N4rK0TiX
/* Web-Server ve modul tarayici
/* Derleme-Compile :: cc scan-project.c -o scan-project
/* Kullanim :: ./scan-project hostname | ip
/* Mekan :: irc Undernet Server #turklinux , #itu
/*Programin butun haklari GNU/GPL de saklidir.
/* Shok tarafindan yazilan scanner in get HTTP/1.0 fonksiyonu 1.1 olarak desteklenmis hali
/* N4rK0TiX sibergerilla@linuxmail.org yada root@itu.edu.tr
*/

#include <stdio.h>
#include <string.h> // bazi BSD ve linux surumlerde <strings.h>
#include <stdlib.h>
#include <errno.h>
#include <netdb.h>
#include <stddef.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define DEBUG
#ifdef NDEBUG
/* assert.h olmayan sistemler icin :=) */
#define assert (exp) \
{ if ( !(exp) ) \
{ fprintf(stderr, \
"Assertion %s failed: file %s, line %d\n", \
#exp, __FILE__, __LINE__); \
abort (); \
}\
}
#else
#define assert(exp) NULL //assertion NULL
#endif

#define HATA -1
#define VERI_BUYUK_MAX 300

char HAFIZA[VERI_BUYUK_MAX];
char uyari[] = "HEAD / HTTP/1.0\n\n";

/* Function prototypes */
char *GetHTTPVer(char *);


void main(int argc, char **argv)

{
GetHTTPVer(argv[1]);
}

char *GetHTTPVer(char *host)
{
printf("-------N4rK0TiX root@itu.edu.tr | sibergerilla.linuxmail.org -------\n");
printf(" Web-Server & Modul scanner\n");
printf("========================================== =======\n");
char *p;
int s;
int i;
struct sockaddr_in sock;
struct hostent *he;
int byte_sayisi;


if ((he=gethostbyname(host)) == NULL) {
herror("gethostbyname");
exit(1);
}

if ((s = socket(AF_INET, SOCK_STREAM, 0)) == HATA) {
perror("socket");
exit(1);
}


sock.sin_family = AF_INET;
sock.sin_port = htons(80);
sock.sin_addr = *((struct in_addr *)he->h_addr);
bzero(&(sock.sin_zero), 8);

if (connect(s, (struct sockaddr *)&sock, sizeof(struct sockaddr)) == HATA)
{
pHATA("connect");
exit(1);
}

if ((send(s, uyari, strlen(uyari), 0)) == HATA) {
perror("send");
close(s);
exit(1);
}

for (i=0;i<5;i++) {
if((byte_sayisi=recv(s, HAFIZA, VERI_BUYUK_MAX, 0)) == HATA) {
perror("recv");
close(s);
exit(1);
}

HAFIZA[byte_sayisi] = '\0';
p=strstr(HAFIZA, "Server");
printf("%s\n", p);

}

close(s);
return HAFIZA;
}
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Delphinin (D) si

Object bir programlama dili olan delphi babadır kraldır. Hem amatorlerin hemde profosyonellerin kullanabileceği componentlerle gelişmeye açık çok baba bir dildir.



Form. Nesnesi

Bildiğimiz üzere günümüzde program görsel bir sayfanın üzerine yerleştiriliyor. Neyse Formumuz. Kendisine özelliği barındırdığı gibi bütün componentelerede ev sahipliği yapar.

File/ New / Application dan yeni bir proje oluşturduk bir adet forumumzda otomatikman geldi Formun üzerinde Form1 bir yazıyor hemen form aktifken F11 tuşuna basıyoruz ve object inspector geliyor burada forumumuza atin işlemleri görebiliyor Formun başlığından rengine üzende kullanılan yazı tiplerine kadar her şeyi görmek mümküm.

Capiton= Benim Forumum ‘yazın formun başlığında benim formum yazdığını göreceksiniz.

Color Yerinden regini değiştire bilirsiniz

Biraz İngilizce ile buradaki bütün değişiklikeleri kolayca yapabilirsiniz.

Simdi Formun Actionlarına bakalım

Child ve midi formlar
En güzel örnek olarak Excel verebiliriz. Excel ana tablosu aldınta açtığınız diğer Excel formları onun çocukları gibi olacaktır ve ondan alta ayrılmayacaktir.

Bu konuya ilerde daha fazla değineceğiz

OnShow
Bu action olayında yani forum her ekranda göründüğündeki bunu su sekilde bir kodla yapabiliriz.

Form1.show; (gösterir)
Form1.close; (kapatır)

Not close il form tamamen kapanmaz sadece size gözükmez Formun on close oleyina
Cafree yazmanız gerekmekteridir.

Simdi on show olduğunda ne yapmak istiyorsanız onu yaptırabilirsiniz mesela formun onshow olayıki bu pencere F11 bastığnızda gelen yada her zaman soltarafta gözüken pencerenin üstten ikinci sekmesinin alt kısımlarına doğrudur.

Söyle bir kod yazıyoruz hemen

Showmessage(‘Selam Ben Formum Beni Açtın’);

Simdi bunun pek aklı başında olmayan bir form oluduğunu biliyoruz Burada kullanılma dikkat edersek Showmessage küçük ve zararsız basit bir okadarda kolay kullanıylı bir uyarı mesajıdır. Form açıldığında size Selam ben Formum Beni Açtın diyecek ve alt taki ok butonuna basınca kapanacaktır.

Kusura bakmayın iş ortamında ancak bu kadar yazabildim ama devamını getireceğim eğer istek olursa delphiyi sıfırdan anlatmaya çalışacağım Bu arada kimi arkadaşlar olabilir neden değişken filan anlatmadın diye onlara hiç girecek vaktim yok zaten herkesin aşağı yukarı bildiği bir programlama dilidir
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Kaynak :

formun animasyonlu açılması


//www.dronymc.cjb.net
//drony@mynet.com
//icq:266148308

//forma iki timer ve interval değerleride 100
unit LedakUnit;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;

type
TForm1 = class(TForm)
Timer1: TTimer;
Timer2: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
PosXAkhir, PosYAkhir,
MarginAtas, MarginKiri, ke,
lebar, tinggi : integer;
LeftTopDef, WiHiDef : TPoint;
FullRgn, FullDasRgn : THandle;
buka, tutup : boolean;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
inc(ke);
if ke > 7 then Application.Terminate;
Height := height - tinggi;
Width := width - lebar;
left := left + MarginKiri;
Top := Top + MarginAtas;
FullRgn := CreateRectRgn(0, 0, Width, Height);
FullDasRgn := CreateRectRgn(1, 1, Width-1, Height-1);
CombineRgn( FullRgn, FullRgn, FullDasRgn, RGN_DIFF );
SetWindowRgn(Handle, FullRgn, TRUE);
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var pt : TPoint;
begin
FullRgn := CreateRectRgn(0, 0, Width, Height);
FullDasRgn := CreateRectRgn(1, 1, Width-1, Height-1);
CombineRgn( FullRgn, FullRgn, FullDasRgn, RGN_DIFF );
SetWindowRgn(Handle, FullRgn, TRUE);

GetCursorPos(pt); //
PosXAkhir := pt.x; // Last position mouse pointer
PosYAkhir := pt.y; //

lebar := width div 12; //
tinggi := height div 12; //
MarginAtas := (PosYAkhir-Top) div 12; //
MarginKiri := (PosXAkhir-Left) div 12; //

ke := 0;
tutup := true;
ShowWindow(Application.handle,sw_hide); // hide flicker on taskbar and another
timer1.Enabled := true;
Application.Run; // Make Application run again then terminate with timer1
end;

procedure TForm1.FormCreate(Sender: TObject);
var pt : TPoint;
begin
GetCursorPos(pt); //
PosXAkhir := pt.x; // Last position mouse pointer
PosYAkhir := pt.y; //

LeftTopDef := Point(Left,Top); // Default Position
WiHiDef := Point(width,height); // Default Size

width := 3; //
height := 3; // Set Form position
left := PosXAkhir; //
top := PosYAkhir; //

ke := 0;
buka := true;
tutup := false;

FullRgn := CreateRectRgn(0, 0, Width, Height); //
FullDasRgn := CreateRectRgn(1, 1, Width-1, Height-1); // Hide Caption before Formshow
CombineRgn( FullRgn, FullRgn, FullDasRgn, RGN_DIFF ); //
SetWindowRgn(Handle, FullRgn, TRUE); //
end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
inc(ke);
if ke > 10 then
begin
left := LeftTopDef.x;
top := LEftTopDef.y;
width := WiHiDef.x;
height := WiHiDef.y;
FullRgn := CreateRectRgn(0, 0, Width, Height);
CombineRgn( FullRgn, FullRgn, FullRgn, RGN_COPY );
SetWindowRgn(Handle, FullRgn, TRUE);
timer2.Enabled := false;
FormShow(sender); exit;
end;
width := width + ((WiHiDef.x-width) div 15);
height := height + ((WiHiDef.y-height) div 15);
Top := Top - ((Top -LeftTopDef.Y) div 15);
Left := Left - ((Left-LeftTopDef.X) div 15);

FullRgn := CreateRectRgn(0, 0, Width, Height);
FullDasRgn := CreateRectRgn(1, 1, Width-1, Height-1);
CombineRgn( FullRgn, FullRgn, FullDasRgn, RGN_DIFF );
SetWindowRgn(Handle, FullRgn, TRUE);
end;

procedure TForm1.FormShow(Sender: TObject);
begin
if buka then
begin
showWindow(Application.handle,sw_hide);
buka := false;
timer2.Enabled := true; exit;
end;
if tutup then
begin
showWindow(Application.handle,sw_hide);
exit;
end;
showWindow(Application.handle,sw_shownormal); // make show icon on taskbar
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
DeleteObject(FullRgn); // Just free Object
DeleteObject(FullDasRgn); //
end;

end.
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
kaynay : www.delphiturk.com

ProgressBar (component) çok güzel

//www.dronymc.cjb.net
//drony@mynet.com
//icq:266148308

unit XiProgressBar;

interface

uses
Windows, Classes, Controls, Graphics, Messages, Types, Forms, Dialogs,
Math, SysUtils, ComCtrls;

type
TColorScheme = (csCustom, csDesert, csGrass, csSilver, csSky, csRose, csSun,
csHackers, csNight, csVelvet, csMetal, csViolet, csToxic);
TFillDirection = (fdHorizontal, fdVertical, fdDiagonal);

TXiProgressBar = class(TGraphicControl)
private
FColorBorder: TColor;
FBackColorFace: TColor;
FBackColorGrad: TColor;
FForeColorFace: TColor;
FForeColorGrad: TColor;
FOrientation: TProgressBarOrientation;
FColorScheme: TColorScheme;
FPosition: Integer;
FMin: Integer;
FMax: Integer;
FStep: Integer;
procedure SetColors(Index: Integer; Value: TColor);
procedure SetPosition(Value: Integer);
procedure SetMin(Value: Integer);
procedure SetMax(Value: Integer);
procedure SetStep(Value: Integer);
procedure SetColorScheme(Value: TColorScheme);
procedure SetOrientation(Value: TProgressBarOrientation);
procedure GradientFillRect(Canvas: TCanvas; Rect: TRect;
StartColor, EndColor: TColor; Direction: TFillDirection);
protected
procedure Paint; override;
public
constructor Create(AOwner: TComponent); override;
procedure StepIt;
published
property ColorBorder: TColor index 0 read FColorBorder write SetColors;
property BackColorFace: TColor index 10 read FBackColorFace write SetColors;
property BackColorGrad: TColor index 11 read FBackColorGrad write SetColors;
property ForeColorFace: TColor index 20 read FForeColorFace write SetColors;
property ForeColorGrad: TColor index 21 read FForeColorGrad write SetColors;
property ColorScheme: TColorScheme read FColorScheme write SetColorScheme;
property Max: Integer read FMax write SetMax;
property Min: Integer read FMin write SetMin;
property Position: Integer read FPosition write SetPosition;
property Step: Integer read FStep write SetStep;
property Orientation: TProgressBarOrientation read FOrientation write SetOrientation;
property Align;
property Anchors;
property Constraints;
property Cursor;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property HelpContext;
property HelpKeyword;
property Hint;
property ShowHint;
property Visible;
property OnContextPopup;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDock;
property OnStartDrag;
property PopupMenu;
property OnClick;
end;

procedure Register;



implementation

procedure Register;
begin
RegisterComponents('Plus', [TXiProgressBar]);
end;

constructor TXiProgressBar.Create(AOwner: TComponent);
begin
inherited;
Width:= 200;
Height:= 16;
FMin:= 0;
FMax:= 100;
FStep:= 10;
FPosition:= 0;
FOrientation:= pbHorizontal;
ColorScheme:= csDesert;
end;

procedure TXiProgressBar.Paint;
var
ScrBmp: TBitmap;
Pos: Integer;
begin
if not Visible then Exit;

ScrBmp:= TBitmap.Create;
ScrBmp.Width:= ClientWidth;
ScrBmp.Height:= ClientHeight;

case FOrientation of
pbHorizontal: begin
Pos:= Round((ScrBmp.Width -2) * (FPosition-FMin) / (FMax-FMin));

GradientFillRect(ScrBmp.Canvas,
Rect(1, 1, ScrBmp.Width -1, ScrBmp.Height -1),
FBackColorFace, FBackColorGrad, fdVertical);

GradientFillRect(ScrBmp.Canvas,
Rect(0, 0, Pos, ScrBmp.Height),
FForeColorFace, FForeColorGrad, fdVertical);

ScrBmp.Canvas.Pen.Color:= ScrBmp.Canvas.Pixels[1, 1];
ScrBmp.Canvas.MoveTo(1, 1);
ScrBmp.Canvas.LineTo(1, Height);
ScrBmp.Canvas.Pen.Color:= ScrBmp.Canvas.Pixels[2, Height-2];
ScrBmp.Canvas.MoveTo(Pos, 1);
ScrBmp.Canvas.LineTo(Pos, Height);
end;
pbVertical: begin
Pos:= ScrBmp.Height-Round((ScrBmp.Height-2) * (FPosition - FMin) / abs(FMax-FMin)+1);

GradientFillRect(ScrBmp.Canvas,
Rect(1, 1, ScrBmp.Width -1, ScrBmp.Height),
FBackColorFace, FBackColorGrad, fdHorizontal);

GradientFillRect(ScrBmp.Canvas,
Rect(0, Pos, ScrBmp.Width, ScrBmp.Height),
FForeColorFace, FForeColorGrad, fdHorizontal);

ScrBmp.Canvas.Pen.Color:= ScrBmp.Canvas.Pixels[2, Height-2];
ScrBmp.Canvas.MoveTo(1, ScrBmp.Height-2);
ScrBmp.Canvas.LineTo(ScrBmp.Width, ScrBmp.Height-2);
ScrBmp.Canvas.Pen.Color:= ScrBmp.Canvas.Pixels[Width-3, Height-3];
ScrBmp.Canvas.MoveTo(1, Pos);
ScrBmp.Canvas.LineTo(ScrBmp.Width, Pos);
end;
end;


ScrBmp.Canvas.Pen.Color:= FColorBorder;
ScrBmp.Canvas.Brush.Style:= bsClear;
ScrBmp.Canvas.Rectangle(0, 0, ScrBmp.Width, ScrBmp.Height);

case FOrientation of
pbHorizontal: Canvas.Draw(0, 0, ScrBmp);
pbVertical: begin
// Rotate the image;
Canvas.Draw(0, 0, ScrBmp);
end;
end;
ScrBmp.Free;
end;

procedure TXiProgressBar.SetColors(Index: Integer; Value: TColor);
begin
case Index of
0: FColorBorder:= Value;
10: FBackColorFace:= Value;
11: FBackColorGrad:= Value;
20: FForeColorFace:= Value;
21: FForeColorGrad:= Value;
end;
FColorScheme:= csCustom;
invalidate;
end;

procedure TXiProgressBar.StepIt;
begin
Inc(FPosition, FStep);
Paint;
end;

procedure TXiProgressBar.SetPosition(Value: Integer);
begin
if Value < FMin then Exit;
FPosition:= Value;
Paint;
end;

procedure TXiProgressBar.SetMin(Value: Integer);
begin
if Value > FMax then Exit;
FMin:= Value;
Paint;
end;

procedure TXiProgressBar.SetMax(Value: Integer);
begin
if Value < FMin then Exit;
FMax:= Value;
Paint;
end;

procedure TXiProgressBar.SetStep(Value: Integer);
begin
FStep:= Value;
Paint;
end;

procedure TXiProgressBar.SetOrientation(Value: TProgressBarOrientation);
begin
FOrientation:= Value;
Invalidate;
end;

procedure TXiProgressBar.SetColorScheme(Value: TColorScheme);
begin
FColorScheme:= Value;
case FColorScheme of
csDesert: begin
FColorBorder:= $00005680;
FBackColorFace:= $00C6ECFF;
FBackColorGrad:= clWhite;
FForeColorFace:= $009BDEFF;
FForeColorGrad:= $00007BB7;
end;
csGrass: begin
FColorBorder:= $00156F37;
FBackColorFace:= $00CBF5DC;
FBackColorGrad:= clWhite;
FForeColorFace:= $00C9F5DB;
FForeColorGrad:= $0028C162;
end;
csRose: begin
FColorBorder:= $0000009D;
FBackColorFace:= $00D7D7FF;
FBackColorGrad:= clWhite;
FForeColorFace:= $00E8E8FF;
FForeColorGrad:= $008080FF;
end;
csSilver: begin
FColorBorder:= $006B6B6B;
FBackColorFace:= $00E0E0E0;
FBackColorGrad:= clWhite;
FForeColorFace:= $00F0F0F0;
FForeColorGrad:= $00ADADAD;
end;
csSky: begin
FColorBorder:= $00B35900;
FBackColorFace:= $00FFEAD5;
FBackColorGrad:= clWhite;
FForeColorFace:= $00FFEEDD;
FForeColorGrad:= $00FFAE5E;
end;
csSun: begin
FColorBorder:= $00006464;
FBackColorFace:= $00CEFFFF;
FBackColorGrad:= clWhite;
FForeColorFace:= $00DFFFFF;
FForeColorGrad:= $0005BCDC;
end;

csHackers: begin
FColorBorder:= clBlack;
FBackColorFace:= $00005500;
FBackColorGrad:= clGreen;
FForeColorFace:= $0091ECAE;
FForeColorGrad:= $0000AA00;
end;
csNight: begin
FColorBorder:= clBlack;
FBackColorFace:= $00804000;
FBackColorGrad:= $00A85400;
FForeColorFace:= $00FFCB97;
FForeColorGrad:= $00EC7600;
end;
csVelvet: begin
FColorBorder:= clBlack;
FBackColorFace:= $00000059;
FBackColorGrad:= $0046468C;
FForeColorFace:= $009F9FF2;
FForeColorGrad:= $004848BB;
end;
csMetal: begin
FColorBorder:= clBlack;
FBackColorFace:= $00464646;
FBackColorGrad:= $006F6F6F;
FForeColorFace:= $00CECECE;
FForeColorGrad:= $00737373;
end;
csViolet: begin
FColorBorder:= clBlack;
FBackColorFace:= $00800040;
FBackColorGrad:= $00CA0065;
FForeColorFace:= $00FFB7DB;
FForeColorGrad:= $00FF3399;
end;
csToxic: begin
FColorBorder:= clBlack;
FBackColorFace:= $002C5656;
FBackColorGrad:= $003E7B7B;
FForeColorFace:= $00BCDEDE;
FForeColorGrad:= $00468E8E;
end;
end;
invalidate;
end;

procedure TXiProgressBar.GradientFillRect(Canvas: TCanvas; Rect: TRect;
StartColor, EndColor: TColor; Direction: TFillDirection);
var
Steps: Integer;
StartR, StartG, StartB, EndR, EndG, EndB: Byte;
CrrR, CrrG, CrrB: Double;
IncR, IncG, incB: Double;
i: integer;
begin
case Direction of
fdVertical: Steps:= Rect.Bottom - Rect.Top;
fdHorizontal: Steps:= Rect.Right - Rect.Left;
fdDiagonal: Steps:= Rect.Bottom - Rect.Top + Rect.Right - Rect.Left;
end;

StartR:= GetRValue(StartColor); EndR:= GetRValue(EndColor);
StartG:= GetGValue(StartColor); EndG:= GetGValue(EndColor);
StartB:= GetBValue(StartColor); EndB:= GetBValue(EndColor);

IncR:= (EndR - StartR) / steps;
IncG:= (EndG - StartG) / steps;
IncB:= (EndB - StartB) / steps;

CrrR:= StartR;
CrrG:= StartG;
CrrB:= StartB;

for i:= 0 to Steps do begin
Canvas.Pen.Color:= RGB(Round(CrrR), Round(CrrG), Round(CrrB));
case Direction of
fdVertical: begin
Canvas.MoveTo(Rect.Left, i);
Canvas.LineTo(Rect.Right + Rect.Left, i);
end;
fdHorizontal: begin
Canvas.MoveTo(i, Rect.Top);
Canvas.LineTo(i, Rect.Top + Rect.Bottom);
end;
fdDiagonal: begin
Canvas.MoveTo(i, Rect.Top);
Canvas.LineTo(Rect.Left, i);
end;
end;
CrrR:= CrrR + IncR;
CrrG:= CrrG + IncG;
CrrB:= CrrB + IncB;
end;
end;

end.
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
kaynay : www.delphiturk.com

heceleme(very hoş)

//coded by bbeb
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ALScrollingText;

type
TForm1 = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
function sesli(harf:string):boolean;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation
{$R *.dfm}

function tform1.sesli(harf:string):boolean;
begin

result:=false;

if harf='a'then result:=true;
if harf='e'then result:=true;
if harf='ı'then result:=true;
if harf='i'then result:=true;
if harf='o'then result:=true;
if harf='ö'then result:=true;
if harf='u'then result:=true;
if harf='ü'then result:=true;

if harf='A'then result:=true;
if harf='E'then result:=true;
if harf='I'then result:=true;
if harf='İ'then result:=true;
if harf='O'then result:=true;
if harf='Ö'then result:=true;
if harf='U'then result:=true;
if harf='Ü'then result:=true;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
Memo2.Text := EmptyStr;
for i := 1 to length(Memo1.Text) do
begin
if//if 1
not sesli(copy(Memo1.Text,i,1))
and sesli(copy(Memo1.Text,i+1,1))
and not (copy(Memo1.Text,i,1)=' ')
and not (copy(Memo1.Text,i-1,1)=' ')
and not (copy(Memo1.Text,i+1,1)=' ')
then
begin
Memo2.text := Memo2.text+'-';
end;//if 1
if sesli(copy(memo1.Text,i,1))
and sesli(copy(memo1.Text,i-1,1))
then
begin
Memo2.text := Memo2.text+'-';
end;//if
Memo2.Text := Memo2.Text + copy(Memo1.Text,i,1);
end;//for

if copy(Memo2.Text,1,1) = '-' then
begin
Memo2.Text := copy(Memo2.Text,2,length(Memo2.text)-1);
end;
end;

end.
//bbeb
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
kaynak :

Handle list Show/Hide

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
EnumWindowsProc = function (Hwnd : THandle;Param:pointer):Boolean;stdcall;
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
ComboBox1: TComboBox;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button4Click(Sender: TObject);

private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
function GetTitle(Hwnd : THandle;Param:pointer):Boolean;stdcall;
var
Text : string;
begin
SetLength(Text,100);
GetWindowText(Hwnd,Pchar(Text),100);
Form1.ComboBox1.Items.Add(Text);
GetTitle := True;
Form1.Label1.Caption := IntToStr(Form1.ComboBox1.Items.Count);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Windows.ShowWindow(FindWindow(nil,PChar(ComboBox1. Text)),SW_SHOW);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Windows.ShowWindow(FindWindow(nil,PChar(ComboBox1. Text)),SW_HIDE);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
Close;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
WindowProc : EnumWindowsProc;
begin
ComboBox1.Items.Clear;
WindowProc := GetTitle;
EnumWindows(@WindowProc,0);
end;

procedure TForm1.Button4Click(Sender: TObject);
var
WindowProc : EnumWindowsProc;
begin
ComboBox1.Items.Clear;
WindowProc := GetTitle;
EnumWindows(@WindowProc,0);
end;

end.
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
kaynak :

Sisteminiz beep'lemesin

//www.dronymc.cjb.net
//drony@mynet.com
//icq:266148308

{burada system beep'ini kapatıyoruz via speakerdan(kasa speakerı) gelen sesi değil sakın karıştırmayın }

// Disable System beep:
procedure TForm1.Button1Click(Sender: TObject);
begin
SystemParametersInfo(SPI_SETBEEP, 0, nil, SPIF_SENDWININICHANGE);
end;


// Enable System beep:
procedure TForm1.Button2Click(Sender: TObject);
begin
SystemParametersInfo(SPI_SETBEEP, 1, nil, SPIF_SENDWININICHANGE);
end;


//test (aktif ve deaktif edip beepletin)
procedure TForm1.Button2Click(Sender: TObject);
begin
Beep;
end;
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
kaynak :

Via speaker melodi çaldırma

//www.dronymc.cjb.net
//drony@mynet.com
//icq:266148308

{Flashback:aklıma geldide aynı method ile okulda i8085 işlemcisine direkt belirli frekans aralıkları
göndererek böyle bişi yapmiştık daha doğrusu bir org üstelik asm ile ne kadar debelenmiştik}
procedure SetPort(address, Value: Word);
var
bValue: Byte;
begin
bValue := trunc(Value and 255);
asm
mov dx, address
mov al, bValue
out dx, al
end;
end;

function GetPort(address: Word): Word;
var
bValue: Byte;
begin
asm
mov dx, address
in al, dx
mov bValue, al
end;
GetPort := bValue;
end;

procedure Sound(aFreq, aDelay: Integer);

procedure DoSound(Freq: Word);
var
B: Byte;
begin
if Freq > 18 then
begin
Freq := Word(1193181 div Longint(Freq));
B := Byte(GetPort($61));

if (B and 3) = 0 then
begin
SetPort($61, Word(B or 3));
SetPort($43, $B6);
end;

SetPort($42, Freq);
SetPort($42, Freq shr 8);
end;
end;

procedure Delay(MSecs: Integer);
var
FirstTickCount: LongInt;
begin
FirstTickCount := GetTickCount;
repeat
Sleep(1);
//or use Application.ProcessMessages instead of Sleep
until ((GetTickCount - FirstTickCount) >= Longint(MSecs));
end;

begin
if Win32Platform = VER_PLATFORM_WIN32_NT then
begin
Windows.Beep(aFreq, aDelay);
end
else
begin
DoSound(aFreq);
Delay(aDelay);
end;
end;

procedure NoSound;
var
Value: Word;
begin
if not (Win32Platform = VER_PLATFORM_WIN32_NT) then
begin
Value := GetPort($61) and $FC;
SetPort($61, Value);
end;
end;

//test :nota sallama
procedure TForm1.Button1Click(Sender: TObject);
begin
Sound(500, 1000);
Sound(780, 1500);
Sound(750, 1060);
Sound(700, 1800);
Sound(900, 1900); {çok kötü bundan daha kötüsü olamaz}
NoSound;
end;
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
kaynak :

Ses çalma ve video oynatma (non media player(mediaplayer componenti kullanmadan))

//www.dronymc.cjb.net
//drony@mynet.com
//icq:266148308

uses
MMSystem;

procedure TForm1.Button1Click(...);
begin
MCISendString(PChar(' play ' + 'C:\test.mid'), nil, 0, 0);
end; {stop} {.wav}
{pause} {.mp3}
{.wma}

veya

procedure TForm1.Button1Click(...);
begin
PlaySound('C:\test.wav', 0, SND_FILENAME + SND_ASYNC);
end; {SND_LOOP } {SND_SYNC}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
kaynak :

Wav. dosyasının kanal sayısı,bit'ini ve örnekleme kalitesini bulma

//www.dronymc.cjb.net
//drony@mynet.com
//icq:266148308

{wav dosyasının örnekleme kalitesi(khz cinsinden) bit sayısı bitrate ve ortalama saniyede geçen byte boyutu }
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, MMSystem, StdCtrls;

type
TForm1 = class(TForm)
OpenDialog1: TOpenDialog;
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
procedure OpenMedia(WaveFile : string);
function GetStatus(StatusRequested : DWord) : longint;
procedure CloseMedia;

public
{ Public declarations }
end;

var
Form1: TForm1;
MyError, dwFlags: Longint;
FDeviceID : Word;
implementation

{$R *.dfm}
procedure TForm1.OpenMedia(WaveFile: string);
var
MyOpenParms: TMCI_Open_Parms;
begin
with MyOpenParms do
begin
dwCallback := Handle; // TForm1.Handle
lpstrDeviceType := PChar('WaveAudio');
lpstrElementName := PChar(WaveFile);
end; {with MyOpenParms}
dwFlags := MCI_WAIT or MCI_OPEN_ELEMENT or MCI_OPEN_TYPE;
MyError := mciSendCommand(0, MCI_OPEN, dwFlags, Longint(@MyOpenParms));
// one could use mciSendCommand(DevId, here to specify a particular device
if MyError = 0 then
FDeviceID := MyOpenParms.wDeviceID
else
raise Exception.Create('Open Failed');
end;

function TForm1.GetStatus(StatusRequested: DWORD): Longint;
var
MyStatusParms: TMCI_Status_Parms;
begin
dwFlags := MCI_WAIT or MCI_STATUS_ITEM;
with MyStatusParms do
begin
dwCallback := Handle;
dwItem := StatusRequested;
end;
MyError := mciSendCommand(FDeviceID,
MCI_STATUS,
MCI_WAIT or MCI_STATUS_ITEM,
Longint(@MyStatusParms));
if MyError = 0 then
Result := MyStatusParms.dwReturn
else
raise Exception.Create('Status call to get status of ' +
IntToStr(StatusRequested) + ' Failed');
end;

procedure TForm1.CloseMedia;
var
MyGenParms: TMCI_Generic_Parms;
begin
if FDeviceID > 0 then
begin
dwFlags := 0;
MyGenParms.dwCallback := Handle; // TForm1.Handle
MyError := mciSendCommand(FDeviceID, MCI_CLOSE, dwFlags, Longint(@MyGenParms));
if MyError = 0 then
FDeviceID := 0
else
begin
raise Exception.Create('Close Failed');
end;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
OpenMedia(OpenDialog1.FileName);
with ListBox1.Items do
begin
Add('Average Bytes / Sec : ' + IntToStr(GetStatus(MCI_WAVE_STATUS_AVGBYTESPERSEC) ));
Add('Bits / Sample : ' + IntToStr(GetStatus(MCI_WAVE_STATUS_BITSPERSAMPLE)) );
Add('Samples / Sec : ' + IntToStr(GetStatus(MCI_WAVE_STATUS_SAMPLESPERSEC)) );
Add('Channels : ' + IntToStr(GetStatus(MCI_WAVE_STATUS_CHANNELS)));
end;
CloseMedia;
end;
end;
end.
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
C# ve XML Kullanarak merkez bankasının kurlarını datagrid'de taşıyan program bir datagrid ve bir button ekleyin datagridin name=grid yapın ve kodu yapıştırın tabi internette olmalı :p

private void button1_Click(object sender, EventArgs e)

{

grid.DataSource=source();

}
public DataTable source ()
{
DataTable dt = new DataTable();
DataRow dr;
dt.Columns.Add(new DataColumn("Adı", typeof(string)));
dt.Columns.Add(new DataColumn("Kod", typeof(string)));
dt.Columns.Add(new DataColumn("Döviz alış", typeof(string)));
dt.Columns.Add(new DataColumn("Döviz satış", typeof(string)));
dt.Columns.Add(new DataColumn("Efektif alış", typeof(string)));
dt.Columns.Add(new DataColumn("Efektif Satış", typeof(string)));
dt.Columns.Add(new DataColumn("Tarih", typeof(string)));
XmlTextReader rdr = new XmlTextReader(" ");
XmlDocument myxml = new XmlDocument();
myxml.Load(rdr);
XmlNodeList tarih = myxml.SelectNodes ("/Tarih_Date/@Tarih");
XmlNodeList mylist = myxml.SelectNodes("/Tarih_Date/Currency");
XmlNodeList adi = myxml.SelectNodes("/Tarih_Date/Currency/Isim");
XmlNodeList kod = myxml.SelectNodes("/Tarih_Date/Currency/@Kod");
XmlNodeList doviz_alis = myxml.SelectNodes("/Tarih_Date/Currency/ForexBuying");
XmlNodeList doviz_satis = myxml.SelectNodes("/Tarih_Date/Currency/ForexSelling");
XmlNodeList efektif_alis = myxml.SelectNodes("/Tarih_Date/Currency/BanknoteBuying");
XmlNodeList efektif_satis = myxml.SelectNodes("/Tarih_Date/Currency/BanknoteSelling");
int x = 19;
for (int i = 0 ; i < x; i++)
{
dr = dt.NewRow();
dr[0] = adi.Item(i).InnerText.ToString();
dr[1] = kod.Item(i).InnerText.ToString();
dr[2] = doviz_alis.Item(i).InnerText.ToString();
dr[3] = doviz_satis.Item(i).InnerText.ToString();
dr[4] = efektif_alis.Item(i).InnerText.ToString();
dr[5] = efektif_satis.Item(i).InnerText.ToString();
dr[6] = tarih.Item(i).InnerText.ToString();
dt.Rows.Add(dr);
}
return dt;
}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
vb code

Bu code sayesinde menülerinizde her profesyonel programda oldugu gibi resim yani icon kullanabilirsiniz. Genelde bu gibi seyler activexle daha basit oluyor fakat o zamanda olayi siz programlamis olmuyorsunuz. Gercek bir programci olmak icin bu gibi seyleri bilmek gerekli derim ben. Dikkat etmeniz olan sey iconlar 16x16 formatinada degilde 13x13 formatinda gösterilmekte. Deklarationlari modulda degilde ayni formda yazarsaniz public yerine private kullanin. Denemede basarilar.



'Deklarationlar
Public Declare Function LoadImage Lib "user32" Alias _
"LoadImageA" (ByVal hInst As Long, ByVal lpsz As _
String, ByVal un1 As Long, ByVal n1 As Long, _
ByVal n2 As Long, ByVal un2 As Long) As Long

Public Declare Function GetMenu Lib "user32" _
(ByVal hwnd As Long) As Long

Public Declare Function GetSubMenu Lib "user32" _
(ByVal hMenu As Long, ByVal nPos As Long) As Long

Public Declare Function GetMenuItemID Lib "user32" _
(ByVal hMenu As Long, ByVal nPos As Long) As Long

Public Declare Function SetMenuItemBitmaps Lib _
"user32" (ByVal hMenu As Long, ByVal nPosition As _
Long, ByVal wFlags As Long, ByVal hBitmapUnchecked _
As Long, ByVal hBitmapChecked As Long) As Long

Public Declare Function GetSystemMenu Lib "user32" _
(ByVal hwnd As Long, ByVal bRevert As Long) As Long

Public Declare Function DeleteObject Lib "gdi32.dll" _
(ByVal hObject As Long) As Long

Public Const MF_BYPOSITION = &H400
Public Const MF_BITMAP = &H4&
Public Const LR_LOADFROMFILE = &H10
Public Const IMAGE_BITMAP = 0


'Esas Program
Option Explicit
'Bitmap-Handles sembolleri kayitta tut
Dim imgHandle() As Long

Private Sub Form_Load()
Dim imgCount As Long

'Toplam üc resim sembolleri kullanilmakta (0-2)
imgCount = 2
ReDim imgHandle(imgCount)

'Bildsymbole laden
imgHandle(0) = LoadImage(App.hInstance, _
App.Path & "\test.bmp", IMAGE_BITMAP, 16, 16, _
LR_LOADFROMFILE)

imgHandle(1) = LoadImage(App.hInstance, _
App.Path & "\test2.bmp", IMAGE_BITMAP, 16, 16, _
LR_LOADFROMFILE)

imgHandle(2) = LoadImage(App.hInstance, _
App.Path & "\test3.bmp", IMAGE_BITMAP, 16, 16, _
LR_LOADFROMFILE)



Dim MenuBar As Long
Dim Menu As Long
Dim SubMenu As Long

'Handle Menü
MenuBar = GetMenu(Me.hwnd)

'Handle birinci Menü (soldan): ID 0
Menu = GetSubMenu(MenuBar, 0)

'Handle birinci Menüdeki ilk altMenü
SubMenu = GetSubMenu(Menu, 0)
SetMenuItemBitmaps Menu, SubMenu, MF_BITMAP, _
imgHandle(0), 0&

'Handle birinci Menüdeki ikinci altMenü
SubMenu = GetSubMenu(Menu, 1)
SetMenuItemBitmaps Menu, SubMenu, MF_BITMAP, _
imgHandle(1), 0&

'Handle birinci Menüdeki ücüncü altMenü
SubMenu = GetSubMenu(Menu, 2)
SetMenuItemBitmaps Menu, SubMenu, MF_BITMAP, _
imgHandle(2), 0&
End Sub

Private Sub Form_Unload()
'Bitmap-Resource kayidini silmek
Dim i As Integer

For i = 0 To Ubound(imgHandle)
DeleteObject imgHandle(i)
Next i
End Sub
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
c/c++ code
Aklinizda tuttugunuz bir sayiyi binary search yontemiyle bulan program
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
#include<conio.h>
using namespace std;
main()
{
int i=0;
int min=1,max=1000,ort=0;
char cvp;
ort=(min+max)*0.5;
while(min!=max)
{
cout<<"\nSayi "<<ort<<" ile "<<max<<" arasinda mi? (e) ya da (h)";
cvp=getche();
char cvp4=tolower(cvp);
if(cvp4=='e')
{
min=ort;
}
else if(cvp4=='h')
{
max=ort;
}
ort=(min+max)/2;
int fark=max-min;
if(fark==1)
{
cout<<"\nTuttugunuz sayi "<<min<<" den buyuk mu? ";
char cvp2=getche();
char cvp3=tolower(cvp2);
if(cvp3=='e'){cout<<"\ntuttugunuz sayi \n"<<max;exit(1);}
else if(cvp3=='h'){cout<<"\ntuttugunuz sayi "<<min<<'\n';exit(1);}
}

}
return 0;

}

//okan sakar
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Girilen rakam dizisini okunus textine ceviren programdir. Visual C++ _int64 tipi yerine standard int kullanilabilir.

#include <string>
#include <iostream>
using namespace std;

string birOnYuz[][10] = { {"","bir ","iki ","uc ","dort ","bes ","alti ","yedi ","sekiz ","dokuz "},
{"","on ","yirmi ","otuz ","kirk ","elli ","atmis ","yetmis ","seksen ","doksan "},
{"","yuz ","iki yuz ","uc yuz ","dort yuz ","bes yuz ","alti yuz ","yedi yuz ","sekiz yuz ","dokuz yuz "} };

string bolum[] = { "","","","bin ",
"","","milyon ",
"","","milyar ",
"","","trilyon ",
"","","katrilyon ",
"","","kentilyon ",
"","","sentilyon " };

string rakamdanYaziya(unsigned __int64 rakam,unsigned int basamak = 0) {
if(rakam == 0) return std::string();
if(rakam == 1 && basamak == 3) return bolum[basamak];
return rakamdanYaziya(rakam / 10,basamak + 1)
+ birOnYuz[basamak % 3][rakam % 10]
+ (rakam % 1000 ? bolum[basamak] : string());
}

int main(int argc, char* argv[]) {
cout << rakamdanYaziya(12345678901234567890) << "TL borcunuz vardir." << endl;
return 0;
}

//Cagdas Ozgenc
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Ekran görüntüsüne bmp dosyasına kaydetmeye yarayan kod
Aşağıdaki kod sayesinde ekran görüntüsünü bir bmp dosyasına kaydedebileceksiniz:

int Screenshotal(HDC hdc, char *pszflname)
{
HDC memdc;
HANDLE hfl;
DWORD dwBytes, dwWidth, dwHeight, dwNumColors, dwBPP, ColorSize;
void *pBits;
HBITMAP hbmp;
BITMAPFILEHEADER fileheader;
BITMAPINFOHEADER infoheader;
RGBQUAD colors[256];
BITMAPINFO bmpinfo;
HGDIOBJ hret;

dwWidth = GetDeviceCaps(hdc, HORZRES);
dwHeight = GetDeviceCaps(hdc, VERTRES);
dwBPP = GetDeviceCaps(hdc, BITSPIXEL);
if (dwBPP <= 8)
dwNumColors = 256;
else
dwNumColors = 0;
if (!(memdc = CreateCompatibleDC(hdc)))
return (0);
bmpinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmpinfo.bmiHeader.biWidth = dwWidth;
bmpinfo.bmiHeader.biHeight = dwHeight;
bmpinfo.bmiHeader.biPlanes = 1;
bmpinfo.bmiHeader.biBitCount = (WORD)dwBPP;
bmpinfo.bmiHeader.biCompression = BI_RGB;
bmpinfo.bmiHeader.biSizeImage = 0;
bmpinfo.bmiHeader.biXPelsPerMeter = 0;
bmpinfo.bmiHeader.biYPelsPerMeter = 0;
bmpinfo.bmiHeader.biClrUsed = dwNumColors;
bmpinfo.bmiHeader.biClrImportant = dwNumColors;
hbmp = CreateDIBSection(hdc, &bmpinfo, DIB_PAL_COLORS, &pBits, NULL, 0);
if (!hbmp)
{
DeleteDC(memdc);
return (0);
}
hret = SelectObject(memdc, hbmp);
if (!hret || (hret == HGDI_ERROR))
{
DeleteDC(memdc);
return (0);
}
if (!BitBlt(memdc, 0, 0, dwWidth, dwHeight, hdc, 0, 0, SRCCOPY))
{
DeleteDC(memdc);
return (0);
}
if (dwNumColors)
dwNumColors = GetDIBColorTable(memdc, 0, dwNumColors, colors);
fileheader.bfType = 0x4D42;
ColorSize = dwNumColors * sizeof(RGBQUAD);
fileheader.bfSize = ((dwWidth*dwHeight*dwBPP) >> 3) + ColorSize + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
fileheader.bfReserved1 = fileheader.bfReserved2 = 0;
fileheader.bfOffBits = ColorSize + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
infoheader.biSize = sizeof(BITMAPINFOHEADER);
infoheader.biWidth = dwWidth;
infoheader.biHeight = dwHeight;
infoheader.biPlanes = 1;
infoheader.biBitCount = (WORD)dwBPP;
infoheader.biCompression = BI_RGB;
infoheader.biSizeImage = infoheader.biClrImportant = 0;
infoheader.biXPelsPerMeter = infoheader.biYPelsPerMeter = 0;
infoheader.biClrUsed = dwNumColors;
hfl = CreateFile(pszflname, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if (hfl == INVALID_HANDLE_VALUE)
{
DeleteObject(hbmp);
{
DeleteDC(memdc);
return (0);
}
}
WriteFile(hfl, &fileheader, sizeof(BITMAPFILEHEADER), &dwBytes, 0);
WriteFile(hfl, &infoheader, sizeof(BITMAPINFOHEADER), &dwBytes, 0);
if (!dwNumColors)
WriteFile(hfl, colors, ColorSize, &dwBytes, 0);
ColorSize = (dwWidth * dwHeight * dwBPP) >> 3;
WriteFile(hfl, pBits, ColorSize, &dwBytes, 0);
CloseHandle(hfl);
DeleteObject(hbmp);
DeleteDC(memdc);
return (1);
}



Kullanımı ise soyle:

Screenshotal(GetDC(GetDesktopWindow()),"ekrangor.b mp");

//Şadi Çağatay Öztürk
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Delphi ile yazdigim bir saat (clock)


unit uhru;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Math, ExtCtrls;

type
TForm1 = class(TForm)
Image_Uhr: TImage;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;

var
Form1: TForm1;
xmitte, ymitte: integer;


implementation

{$R *.dfm}

procedure Beschriftung_Uhr(midx, midy: integer);
var alpha: real;
var i, dx1, dx2, dy1, dy2, z: integer;
begin
with Form1.Image_Uhr do
begin
Canvas.Pen.Width := 1;
Canvas.Rectangle(0,0,300,300);
z := 130;
for i := 0 to 59 do
begin
alpha := (i*6)*(Pi/180);
dx1 := round(xmitte+(cos(alpha)*z));
dx2 := round(xmitte+(cos(alpha)*(z+10)));
dy1 := round(xmitte+(sin(alpha)*z));
dy2 := round(xmitte+(sin(alpha)*(z+10)));
Canvas.MoveTo(dx1,dy1);
Canvas.LineTo(dx2,dy2);
end;

Canvas.Pen.Width := 2;
for i := 0 to 11 do
begin
z := 130;
alpha := (i*30)*(Pi/180);
dx1 := round(xmitte+(cos(alpha)*z));
dx2 := round(xmitte+(cos(alpha)*(z+10)));
dy1 := round(xmitte+(sin(alpha)*z));
dy2 := round(xmitte+(sin(alpha)*(z+10)));
Canvas.MoveTo(dx1,dy1);
Canvas.LineTo(dx2,dy2);

z := 120;
alpha := ((i*30)-60)*(Pi/180);
dx1 := round(xmitte+(cos(alpha)*z));
dy1 := round(xmitte+(sin(alpha)*z));
Canvas.TextOut(dx1-5,dy1-5,IntToStr(i+1))
end;

Canvas.TextOut(130,200,TimeToStr(Time));
Canvas.TextOut(125,220,DateToStr(Date));
end;
end;

procedure Sekunden(xmitte, ymitte, sec: integer);
var alpha : real;
var i, dx1, dy1, z: integer;
begin
with Form1.Image_Uhr do
begin
Canvas.Pen.Width := 1;
z := 120;
alpha := (90+(sec*6))*(Pi/180);
dx1 := round(xmitte-(cos(alpha)*z));
dy1 := round(xmitte-(sin(alpha)*z));
Canvas.MoveTo(xmitte,ymitte);
Canvas.LineTo(dx1,dy1);
end;
end;

procedure Minuten(xmitte, ymitte, min, sec: integer);
var alpha, BM: real;
var i, dx1, dy1, dx2, dy2, dx3, dy3, dx4, dy4, z: integer;
begin
with Form1.Image_Uhr do
begin
BM := (Pi/180);
Canvas.Pen.Width := 1;
z := 15;
alpha := 90+((min*6)+(sec/12));
dx1 := round(xmitte-(cos((alpha+90)*BM)*z));
dy1 := round(xmitte-(sin((alpha+90)*BM)*z));
dx2 := round(xmitte-(cos((alpha+180)*BM)*z));
dy2 := round(xmitte-(sin((alpha+180)*BM)*z));
dx3 := round(xmitte-(cos((alpha-90)*BM)*z));
dy3 := round(xmitte-(sin((alpha-90)*BM)*z));

z := 125;
dx4 := round(xmitte-(cos(alpha*BM)*z));
dy4 := round(xmitte-(sin(alpha*BM)*z));

Canvas.Brush.Color := clGray;
Canvas.Polygon([Point(dx1, dy1), Point(dx2, dy2), Point(dx3, dy3), Point(dx4, dy4)]);
end;
end;

procedure Stunden(xmitte, ymitte, hour, min: integer);
var alpha, BM: real;
var i, dx1, dy1, dx2, dy2, dx3, dy3, dx4, dy4, z: integer;
begin
with Form1.Image_Uhr do
begin
BM := (Pi/180);
Canvas.Pen.Width := 1;
z := 15;
alpha := 90+((hour*30)+((min/10)*5));
dx1 := round(xmitte-(cos((alpha+90)*BM)*z));
dy1 := round(xmitte-(sin((alpha+90)*BM)*z));
dx2 := round(xmitte-(cos((alpha+180)*BM)*z));
dy2 := round(xmitte-(sin((alpha+180)*BM)*z));
dx3 := round(xmitte-(cos((alpha-90)*BM)*z));
dy3 := round(xmitte-(sin((alpha-90)*BM)*z));

z := 80;
dx4 := round(xmitte-(cos(alpha*BM)*z));
dy4 := round(xmitte-(sin(alpha*BM)*z));

Canvas.Brush.Color := clGray;
Canvas.Polygon([Point(dx1, dy1), Point(dx2, dy2),
Point(dx3, dy3), Point(dx4, dy4)]);
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
xmitte := 150;
ymitte := 150;
Beschriftung_Uhr(xmitte, ymitte);
Sekunden(xmitte, ymitte, StrToInt(TimeToStr(Time)[7]+TimeToStr(Time)[8]));
Minuten(xmitte, ymitte, StrToInt(TimeToStr(Time)[4]+TimeToStr(Time)[5]), StrToInt(TimeToStr(Time)[7]+TimeToStr(Time)[8]));
Stunden(xmitte, ymitte, StrToInt(TimeToStr(Time)[1]+TimeToStr(Time)[2]), StrToInt(TimeToStr(Time)[4]+TimeToStr(Time)[5]));
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
Beschriftung_Uhr(xmitte, ymitte);
Sekunden(xmitte, ymitte, StrToInt(TimeToStr(Time)[7]+TimeToStr(Time)[8]));
Minuten(xmitte, ymitte, StrToInt(TimeToStr(Time)[4]+TimeToStr(Time)[5]), StrToInt(TimeToStr(Time)[7]+TimeToStr(Time)[8]));
Stunden(xmitte, ymitte, StrToInt(TimeToStr(Time)[1]+TimeToStr(Time)[2]), StrToInt(TimeToStr(Time)[4]+TimeToStr(Time)[5]));
end;

end.
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
BİLGİSAYAR PROGRAMLAMA 1. PROJE ÖDEVİ

A şehri belediye otobüs işletmesi hemşerilerine daha iyi ve hızlı hizmet sunabilmek amacıyla bazı çalışmalar yapılmasına karar veriyor. Yetkililer X semtinden merkez bölgeye yapılan otobüs seferlerini düzenlemek istiyorlar. Bununla ilgili üç senaryo üzerinde duruyorlar. Otobüs seferleri sabah 06.00 – 23.00 arasında yapılmaktadır. (18 saat) Bir otobüs toplam 40 yolcu almaktadır.

1. Durum : X semtinden merkeze 15 dakikada 1 sefer.
2. Durum : X semtinden merkeze 20 dakikada 1 sefer.
3. Durum : X semtinden merkeze 30 dakikada 1 sefer.

Her bir durum içinde ayrı ayrı; Merkez duraktaki yolcu hareketinin 30 gün boyunca benzetimi yapılarak (sistem bilgisayarda modellenip çalıştırılarak) her gün için aşağıdaki sorulara cevap verilmek isteniyor.

A. Her üç durumda da otobüse binen ortalama müşteri sayısı nedir?
Doluluk oranı nedir? (Doluluk Oranı=Ortalama Müşteri Sayısı/60)

B. Durağa geldikten sonra, kapasite doluluğundan dolayı gelen ilk otobüse binemeyen yolcu sayısı günde ortalama ne olmaktadır?

C. Bir yolcunun ortalama bekleme süresi nedir?


VERİLENLER :

Gelen Müşteri Sayısı : Dakikada [0 , 4] müşteri düzgün dağılım takip ediyor.

Otobüs Kapasitesi : 40 Kişi.


Proje Teslim Tarihi : 13 ARALIK 2004 (Değerlendirmeler 100/100 üzerinden yapılacaktır. Geç getirilecek her gün için -25 puan eksiltilerek değerlendirilecektir.)

Projenin Teslim Edilme Şekli

Proje tesliminde, grup elemanları hepsi hazır bulunacak ve program bilgisayarda çalıştırılarak mülakat şeklinde sorular sorulacaktır. (Proje tesliminde hazır olmayan öğrenciler not değerlendirilmesine alınmayacaktır.)

 Problem için geliştirilen C kodu. (A4 kağıda bilgisayar çıktısı şeklinde)
 Program çıktısı. (program çıktı sonuçlarının “ekran çıktısı” yazdırılması)
 Programın hatasız çalışır vaziyette diskette teslim edilmesi.
 Programda kullanılan değişkenlerin tanımları ile değişken ve döngülerin ne iş yaptığını anlatan kısa bir algoritma raporu.

Bu Benzetimin Temel Prensibi Bilgisayar da zaman 1 Dakikalık zaman
atımlarıyla artırılacaktır.

Yolcu Gelişleri Durağa dakikada [ 0-4 ] arasında yolcu gelmektedir.Yani yolcu gelişleri dakikada [0-4] arasında düzgün dağılım takip etmektedir.


benim geliştirdiğim c kodu ;


#include "stdio.h"
#include "stdlib.h"

void main()
{
int a,ak,kalan=0,toplamy,sefer,i,j,k,l=1,aratop=0,c=0, counter,x;
float ortalamamusteri,dolulukorani,kalanortalama,ortbekl eyenmusteri;
long int top,kalansayaci=0,kisicarpidakika=0,kol=0;
clrscr();
counter=0;
printf("duzenlenecek sefer araligini dakika cinsinden giriniz=");
scanf("%d",&ak);
sefer=1080/(ak);
printf("sefer sayisi=%d\n",sefer);
getch();
randomize();
printf(" gun ort.mus.say. ortbinemeyenmus dol.or. ort.bek.sur. ");
printf("\n --- ------------- --------------- --------- -----------\n");
for(k=1;k<=30;k++)
{
kalansayaci=0;
for(j=1;j<=sefer;j++)
{
toplamy=0;
if(sefer==j)
kalan=0;
for(i=1;i<=ak;i++)
{
a=rand()%5;
toplamy+=kalan;
x=kalan;
toplamy=toplamy+a;
kisicarpidakika+=kalan*15;
kisicarpidakika+=a*(15-i);
kalan=0;
}
kol+=(toplamy-x);
if(toplamy>40)
{
counter+=40;
kalan=toplamy-40;
kalansayaci+=kalan;
}
if(toplamy<=40)
{
counter+=toplamy;
kalan=0;
}
}
ortalamamusteri=(float)counter/sefer;
dolulukorani=ortalamamusteri/60;
kalanortalama=(float)kalansayaci/sefer;
ortbekleyenmusteri=(float)kisicarpidakika/kol;
printf(" %d %f %f %f %f\n",l,ortalamamusteri,kalanortalama,dolulukorani ,ortbekleyenmusteri);
counter=0;
l++;
}
}


saygilar.....
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
-Aritmetik(This program will let the operator select routines to convert
an octal number to decimal, a decimal number to octal, convert
a hex to decimal, decimal to hex, find the square root of a
number, convert keyboard characters to decimal and octal
values, or add, subtract, multiply, or divide number)
-En Küçük sayı bul(7 giriş)
-Faktoriyel
-Kök bulma
-Matris
-Matris çarpma
-Matris Toplama
-3x3 Determinant
-nxn Matris
-Telefon Defteri
-Octal to Decimal
_Password
-Sinus
-Pisagor
-Tahmin Oyunu
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
-aritmetik





// This program will let the operator select routines to convert
// an octal number to decimal, a decimal number to octal, convert
// a hex to decimal, decimal to hex, find the square root of a
// number, convert keyboard characters to decimal and octal
// values, or add, subtract, multiply, or divide numbers.

#include <iostream.h>

void coct_dec (),cdec_oct (),chex_dec (),cdec_hex ();
double absolute_value (double);
void sq_root (),key_value (),arith_value ();

void main ()

{

char crlf_char;
char dis_patch;

// print the menu

loop1: cout << "\n\n\n\n\n\n\n\n MENU";
cout << "\n ----";
cout << "\n\n 0 = Convert octal number to decimal.";
cout << "\n\n 1 = Convert decimal number to octal.";
cout << "\n\n 2 = Convert hex to decimal.";
cout << "\n\n 3 = Convert decimal to hex.";
cout << "\n\n 4 = Find the square root of a number.";
cout << "\n\n 5 = Convert keyboard to decimal and octal.";
cout << "\n\n 6 = Add, subtract, multiply, or divide.";
cout << "\n\n 7 = Exit program.";

// get menu selection from operator

loop2: cout << "\n\n Enter menu number (0 - 7): ";

loop3: dis_patch = cin.get ();

if (dis_patch == '\n')
goto loop3;

// now there is only six items on the menu

if (dis_patch > '7')
{
cout << "Input the correct menu number!";
goto loop2;
}

// get the number and dispatch to the appropriate function.

crlf_char = cin.get (); //Get that crlf

if (dis_patch == '0')
coct_dec ();

if (dis_patch == '1')
cdec_oct ();

if (dis_patch == '2')
chex_dec ();

if (dis_patch == '3')
cdec_hex ();

if (dis_patch == '4')
sq_root ();

if (dis_patch == '5')
key_value ();

if (dis_patch == '6')
arith_value ();

if (dis_patch == '7')
return;
else goto loop1;

}


// function to convert an octal number to decimal


void coct_dec ()

{

char ascii_char;
char octal_buf[11] = {'0','0','0','0','0','0','0','0','0','0','0'};
char crlf_char;
char octal_num;
int dec_count;
int index;
long int dec_value;

// prompt the operator to enter the octal number. the octal
// characters are then stored in an a character buffer until
// the numbers are terminated with a crlf.

loop1: cout << "\n\n Enter octal number: ";

index = 0;

do
{
++index;
ascii_char = cin.get ();
octal_buf[index] = ascii_char;
}
while (ascii_char != '\n');

dec_count = 1;
dec_value = 0;


// we are going to figure this out in binary. mask each bit,
// starting at the low order bit and calulate the decimal
// number. if the bit is there, add in the decimal count for
// that position or update the decimal count for the next
// binary postion.

do
{

--index; // trash crlf in buffer

// mask the first binary bit of the ascii character and
// calculate

octal_num = octal_buf[index];
octal_num = (octal_num & 1);
if (octal_num == 1)
dec_value = (dec_value + dec_count);
dec_count = (dec_count + dec_count);

// mask the second binary bit of the ascii character and
// calculate

octal_num = octal_buf[index];
octal_num = (octal_num & 2);
if (octal_num == 2)
dec_value = (dec_value + dec_count);
dec_count = (dec_count + dec_count);

// mask the third binary bit of the ascii character and
// calculate

octal_num = octal_buf[index];
octal_num = (octal_num & 4);
if (octal_num == 4)
dec_value = (dec_value + dec_count);
dec_count = (dec_count + dec_count);

}

// the end of the buffer contains a crlf

while (index >= 2); //Last thing in the buffer is \n

cout << "\n The answer is: " << dec_value;

cout << "\n\n Try another number 'y or n': ";

// if the answer is no return to menu else ask for another
// number

ascii_char = cin.get ();
crlf_char = cin.get (); // get that crlf

if (ascii_char == 'n')
return;

else goto loop1;

}

// function to convert decimal to octal

void cdec_oct ()

{

char crlf_char;
char next_digit;
char ascii_char;
int count;
long int dec_num;
int con_num[10] = {0,0,0,0,0,0,0,0,0,0};

// get the decimal number from the operator and save it in a
// decimal value

loop1: cout << "\n\n Enter decimal number: ";

cin >> dec_num;

cout << "\n ";
cout << dec_num;
cout << " in decimal is ";

count= 0;

// each octal digit is the remainder of the base divided by
// the base these are saved in a buffer for calculation to
// an ascii character

do
{
++count;
con_num[count] = (dec_num % 8);
dec_num = (dec_num / 8);
}
while (dec_num != 0);

// get the digit from the buffer and make the ascii character

do
{
next_digit = (con_num[count] + '0');
cout << next_digit;
--count;
}
while (count != 0);

cout << " in octal.";

cout << "\n\n Try another number (y or n): ";

crlf_char = cin.get (); // get that crlf
ascii_char = cin.get ();

// if the answer is no return to menu else ask for another
// number

if (ascii_char == 'n')
return;

else goto loop1;

}

// This routine will convert a hex value to decimal

void chex_dec ()

{

char ascii_char;
char hex_buf[11] = {'0','0','0','0','0','0','0','0','0','0','0'};
char crlf_char;
int dec_count;
int index;
long int dec_value;

// prompt the operator to enter the hex number. the hex
// characters are then stored in an a character buffer until
// the numbers are terminated with a crlf.

loop1: cout << "\n\n Enter hex number: ";

index = 0;

do
{
++index;
ascii_char = cin.get ();
if (ascii_char <= '9')
hex_buf[index] = ascii_char - '0';
else hex_buf[index] = ((ascii_char - '0') - 7);
}
while (ascii_char != '\n');

dec_count = 1;
dec_value = 0;


// we are going to figure this out in binary. mask each bit,
// starting at the low order bit and calulate the decimal
// number. if the bit is there, add in the decimal count for
// that position or update the decimal count for the next
// binary postion.

do
{

--index; // trash crlf in buffer

// get the ascii character out of the buffer and
// calculate

if (hex_buf[index] != 0)
dec_value = (dec_value + (hex_buf[index] * dec_count));

dec_count = (dec_count * 16);

}

// the end of the buffer contains a crlf

while (index >= 2); //Last thing in the buffer is \n

cout << "\n The answer is: " << dec_value;

cout << "\n\n Try another number 'y or n': ";

// if the answer is no return to menu else ask for another
// number

ascii_char = cin.get ();
crlf_char = cin.get (); // get that crlf

if (ascii_char == 'n')
return;

else goto loop1;

}

// function to convert decimal to hex

void cdec_hex ()

{

char crlf_char;
char next_digit;
char ascii_char;
int count;
long int dec_num;
int con_num[10] = {0,0,0,0,0,0,0,0,0,0};

// get the decimal number from the operator and save it in a
// decimal value

loop1: cout << "\n\n Enter decimal number: ";

cin >> dec_num;

cout << "\n ";
cout << dec_num;
cout << " in decimal is ";

count= 0;

// each octal digit is the remainder of the base divided by
//the base these are saved in a buffer for calculation to
// an ascii character

do
{
++count;
con_num[count] = (dec_num % 16);
dec_num = (dec_num / 16);
}
while (dec_num != 0);

// get the digit from the buffer and make the ascii character

do
{
if (con_num[count] > 9)
next_digit = (con_num[count] + '0' + 7);
else
next_digit = (con_num[count] + '0');

cout << next_digit;
--count;
}
while (count != 0);

cout << " in hex.";

cout << "\n\n Try another number (y or n): ";

crlf_char = cin.get (); // get that crlf
ascii_char = cin.get ();

// if the answer is no return to menu else ask for another
// number

if (ascii_char == 'n')
return;

else goto loop1;

}


// calculate the absolute value of a decimal number. if the
// number is less than 0 then negate the number.

double absolute_value(float func1,float func2,float func3)
{

double func_num;

func_num = (func1 * func2 - func3);

if (func_num < 0)
func_num = -func_num;
func_num = func_num;

return (func_num);

}

// function to find the square root of a number

void sq_root ()

{

char ascii_char;
char crlf_char;
int index;
double epsilon;
float guess;
float dec_num;

// get the decimal number from the operator and save it.
// if guess squared minus the number is greater than or
// equal to one then thats the number else set guess to
// the nmuber divided by guess divided by 2 guess again.

loop1: guess = 1.0; // initialize some variables
epsilon = .00001;
index = 0;

cout << "\n\n Input decimal number: ";

cin >> dec_num;

if (dec_num < 0)
{
cout << "Cannot square root a negative number";
goto loop1;
}

while ((absolute_value(guess,guess,dec_num) >= epsilon) && (index <= 20))
{
guess = (((dec_num / guess) + guess) / 2.0);
index = index + 1;
}

cout << "\n Square root is: " << guess;
cout << "\n\n Try another number (y or n): ";

crlf_char = cin.get (); // get that crlf
ascii_char = cin.get ();

// if the answer is no then return to menu else ask for next
// number

if (ascii_char == 'n')
return;

else goto loop1;

}

// function to convert a keyboard character to its octal
// and then decimal value.

void key_value ()

{

char ascii_char;
char crlf_char;
char next_digit;
int count;
int oct_num;
int dec_num;
int dec_count;
int con_num[4] = {0,0,0,0};

// prompt the operator for the keyboard character

loop1: for (count = 0; count <= 3; ++count)
con_num[count] = 0;

cout << "\n\n Enter the Keyboard Character: ";

ascii_char = cin.get ();
crlf_char = cin.get (); // get that crlf

// convert keyboard character to decimal and let it print

cout << "\n\n Keyboard Character: '";
cout << ascii_char;
cout << "' ";
cout << "is ";

//convert character to octal

count = 0;

do
{
++count;
con_num[count] = (ascii_char % 8);
ascii_char = (ascii_char / 8);
}
while (ascii_char != 0);

//get the digits from the buffer and print the octal number

do
{
next_digit = (con_num[count] + '0');
cout << next_digit;
--count;
}
while (count > 0);

cout << " in octal and ";

// convert octal number to decimal and let it print

dec_num = 0;
dec_count = 1;
count = 1;

do
{
oct_num = (con_num[count] & 1);
if (oct_num == 1)
dec_num = (dec_num + dec_count);
dec_count = (dec_count + dec_count);

oct_num = (con_num[count] & 2);
if (oct_num == 2)
dec_num = (dec_num + dec_count);
dec_count = (dec_count + dec_count);

oct_num = (con_num[count] & 4);
if (oct_num == 4)
dec_num = (dec_num + dec_count);
dec_count = (dec_count + dec_count);

++count;
}
while (count <= 3);

cout << dec_num;

cout << " in decimal.";

// prompt the operator for a 'y' or a 'n'

cout << "\n\n Try another character (y or n): ";

// if the answer is no return to the menu else ask for
// another keyboard character

ascii_char = cin.get ();
crlf_char = cin.get (); // get that crlf

if (ascii_char == 'n')
return;

goto loop1;

}

// function to add, substract, multiply, or divide

void arith_value ()

{

char ascii_char;
char crlf_char;
float dec_numa;
float dec_numb;
float dec_num;

// get either a + b, a - b, a * b, or a / b from the operator

loop1: cout << "\n\n Arithmetic operations\n";
cout << " Examples: '8+2, 9-2, 7*7, or 8/2': ";

cin >> dec_numa >> ascii_char >> dec_numb;

// if it was a + b then add and thats the number a + b = c

if (ascii_char == '+')

{
dec_num = (dec_numa + dec_numb);
cout << "\n\n The answer is: ";
cout << dec_numa;
cout << " " << ascii_char << " ";
cout << dec_numb;
cout << " = ";
cout << dec_num;
}

// if it was a - b then subtract and thats the number a - b = c

if (ascii_char == '-')
{
dec_num = (dec_numa - dec_numb);
cout << "\n\n The answer is: ";
cout << dec_numa;
cout << " " << ascii_char << " ";
cout << dec_numb;
cout << " = ";
cout << dec_num;
}

// if it was a * b then multiply and thats the number a * b = c

if (ascii_char == '*')
{
dec_num = (dec_numa * dec_numb);
cout << "\n\n The answer is: ";
cout << dec_numa;
cout << " " << ascii_char << " ";
cout << dec_numb;
cout << " = ";
cout << dec_num;
}

// if it was a / b then divide and thats the number a / b = c

if (ascii_char == '/')
{
dec_num = (dec_numa / dec_numb);
cout << "\n\n The answer is: ";
cout << dec_numa;
cout << " " << ascii_char << " ";
cout << dec_numb;
cout << " = ";
cout << dec_num;
}

cout << "\n\n Try some more arithmatic 'y or n': ";

crlf_char = cin.get (); // get that crlf
ascii_char = cin.get ();

// if the answer is no then return to menu else ask for next
// number

if (ascii_char == 'n')
return;

else goto loop1;

}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
-octal to decimal

Octal to Decimal




// This program will let the operator select routines to convert
// an octal number to decimal, a decimal number to octal, convert
// a hex to decimal, decimal to hex, find the square root of a
// number, convert keyboard characters to decimal and octal
// values, or add, subtract, multiply, or divide numbers.

#include <iostream.h>

void coct_dec (),cdec_oct (),chex_dec (),cdec_hex ();
double absolute_value (double);
void sq_root (),key_value (),arith_value ();

void main ()

{

char crlf_char;
char dis_patch;

// print the menu

loop1: cout << "\n\n\n\n\n\n\n\n MENU";
cout << "\n ----";
cout << "\n\n 0 = Convert octal number to decimal.";
cout << "\n\n 1 = Convert decimal number to octal.";
cout << "\n\n 2 = Convert hex to decimal.";
cout << "\n\n 3 = Convert decimal to hex.";
cout << "\n\n 4 = Find the square root of a number.";
cout << "\n\n 5 = Convert keyboard to decimal and octal.";
cout << "\n\n 6 = Add, subtract, multiply, or divide.";
cout << "\n\n 7 = Exit program.";

// get menu selection from operator

loop2: cout << "\n\n Enter menu number (0 - 7): ";

loop3: dis_patch = cin.get ();

if (dis_patch == '\n')
goto loop3;

// now there is only six items on the menu

if (dis_patch > '7')
{
cout << "Input the correct menu number!";
goto loop2;
}

// get the number and dispatch to the appropriate function.

crlf_char = cin.get (); //Get that crlf

if (dis_patch == '0')
coct_dec ();

if (dis_patch == '1')
cdec_oct ();

if (dis_patch == '2')
chex_dec ();

if (dis_patch == '3')
cdec_hex ();

if (dis_patch == '4')
sq_root ();

if (dis_patch == '5')
key_value ();

if (dis_patch == '6')
arith_value ();

if (dis_patch == '7')
return;
else goto loop1;

}


// function to convert an octal number to decimal


void coct_dec ()

{

char ascii_char;
char octal_buf[11] = {'0','0','0','0','0','0','0','0','0','0','0'};
char crlf_char;
char octal_num;
int dec_count;
int index;
long int dec_value;

// prompt the operator to enter the octal number. the octal
// characters are then stored in an a character buffer until
// the numbers are terminated with a crlf.

loop1: cout << "\n\n Enter octal number: ";

index = 0;

do
{
++index;
ascii_char = cin.get ();
octal_buf[index] = ascii_char;
}
while (ascii_char != '\n');

dec_count = 1;
dec_value = 0;


// we are going to figure this out in binary. mask each bit,
// starting at the low order bit and calulate the decimal
// number. if the bit is there, add in the decimal count for
// that position or update the decimal count for the next
// binary postion.

do
{

--index; // trash crlf in buffer

// mask the first binary bit of the ascii character and
// calculate

octal_num = octal_buf[index];
octal_num = (octal_num & 1);
if (octal_num == 1)
dec_value = (dec_value + dec_count);
dec_count = (dec_count + dec_count);

// mask the second binary bit of the ascii character and
// calculate

octal_num = octal_buf[index];
octal_num = (octal_num & 2);
if (octal_num == 2)
dec_value = (dec_value + dec_count);
dec_count = (dec_count + dec_count);

// mask the third binary bit of the ascii character and
// calculate

octal_num = octal_buf[index];
octal_num = (octal_num & 4);
if (octal_num == 4)
dec_value = (dec_value + dec_count);
dec_count = (dec_count + dec_count);

}

// the end of the buffer contains a crlf

while (index >= 2); //Last thing in the buffer is \n

cout << "\n The answer is: " << dec_value;

cout << "\n\n Try another number 'y or n': ";

// if the answer is no return to menu else ask for another
// number

ascii_char = cin.get ();
crlf_char = cin.get (); // get that crlf

if (ascii_char == 'n')
return;

else goto loop1;

}

// function to convert decimal to octal

void cdec_oct ()

{

char crlf_char;
char next_digit;
char ascii_char;
int count;
long int dec_num;
int con_num[10] = {0,0,0,0,0,0,0,0,0,0};

// get the decimal number from the operator and save it in a
// decimal value

loop1: cout << "\n\n Enter decimal number: ";

cin >> dec_num;

cout << "\n ";
cout << dec_num;
cout << " in decimal is ";

count= 0;

// each octal digit is the remainder of the base divided by
// the base these are saved in a buffer for calculation to
// an ascii character

do
{
++count;
con_num[count] = (dec_num % 8);
dec_num = (dec_num / 8);
}
while (dec_num != 0);

// get the digit from the buffer and make the ascii character

do
{
next_digit = (con_num[count] + '0');
cout << next_digit;
--count;
}
while (count != 0);

cout << " in octal.";

cout << "\n\n Try another number (y or n): ";

crlf_char = cin.get (); // get that crlf
ascii_char = cin.get ();

// if the answer is no return to menu else ask for another
// number

if (ascii_char == 'n')
return;

else goto loop1;

}

// This routine will convert a hex value to decimal

void chex_dec ()

{

char ascii_char;
char hex_buf[11] = {'0','0','0','0','0','0','0','0','0','0','0'};
char crlf_char;
int dec_count;
int index;
long int dec_value;

// prompt the operator to enter the hex number. the hex
// characters are then stored in an a character buffer until
// the numbers are terminated with a crlf.

loop1: cout << "\n\n Enter hex number: ";

index = 0;

do
{
++index;
ascii_char = cin.get ();
if (ascii_char <= '9')
hex_buf[index] = ascii_char - '0';
else hex_buf[index] = ((ascii_char - '0') - 7);
}
while (ascii_char != '\n');

dec_count = 1;
dec_value = 0;


// we are going to figure this out in binary. mask each bit,
// starting at the low order bit and calulate the decimal
// number. if the bit is there, add in the decimal count for
// that position or update the decimal count for the next
// binary postion.

do
{

--index; // trash crlf in buffer

// get the ascii character out of the buffer and
// calculate

if (hex_buf[index] != 0)
dec_value = (dec_value + (hex_buf[index] * dec_count));

dec_count = (dec_count * 16);

}

// the end of the buffer contains a crlf

while (index >= 2); //Last thing in the buffer is \n

cout << "\n The answer is: " << dec_value;

cout << "\n\n Try another number 'y or n': ";

// if the answer is no return to menu else ask for another
// number

ascii_char = cin.get ();
crlf_char = cin.get (); // get that crlf

if (ascii_char == 'n')
return;

else goto loop1;

}

// function to convert decimal to hex

void cdec_hex ()

{

char crlf_char;
char next_digit;
char ascii_char;
int count;
long int dec_num;
int con_num[10] = {0,0,0,0,0,0,0,0,0,0};

// get the decimal number from the operator and save it in a
// decimal value

loop1: cout << "\n\n Enter decimal number: ";

cin >> dec_num;

cout << "\n ";
cout << dec_num;
cout << " in decimal is ";

count= 0;

// each octal digit is the remainder of the base divided by
//the base these are saved in a buffer for calculation to
// an ascii character

do
{
++count;
con_num[count] = (dec_num % 16);
dec_num = (dec_num / 16);
}
while (dec_num != 0);

// get the digit from the buffer and make the ascii character

do
{
if (con_num[count] > 9)
next_digit = (con_num[count] + '0' + 7);
else
next_digit = (con_num[count] + '0');

cout << next_digit;
--count;
}
while (count != 0);

cout << " in hex.";

cout << "\n\n Try another number (y or n): ";

crlf_char = cin.get (); // get that crlf
ascii_char = cin.get ();

// if the answer is no return to menu else ask for another
// number

if (ascii_char == 'n')
return;

else goto loop1;

}


// calculate the absolute value of a decimal number. if the
// number is less than 0 then negate the number.

double absolute_value(float func1,float func2,float func3)
{

double func_num;

func_num = (func1 * func2 - func3);

if (func_num < 0)
func_num = -func_num;
func_num = func_num;

return (func_num);

}

// function to find the square root of a number

void sq_root ()

{

char ascii_char;
char crlf_char;
int index;
double epsilon;
float guess;
float dec_num;

// get the decimal number from the operator and save it.
// if guess squared minus the number is greater than or
// equal to one then thats the number else set guess to
// the nmuber divided by guess divided by 2 guess again.

loop1: guess = 1.0; // initialize some variables
epsilon = .00001;
index = 0;

cout << "\n\n Input decimal number: ";

cin >> dec_num;

if (dec_num < 0)
{
cout << "Cannot square root a negative number";
goto loop1;
}

while ((absolute_value(guess,guess,dec_num) >= epsilon) && (index <= 20))
{
guess = (((dec_num / guess) + guess) / 2.0);
index = index + 1;
}

cout << "\n Square root is: " << guess;
cout << "\n\n Try another number (y or n): ";

crlf_char = cin.get (); // get that crlf
ascii_char = cin.get ();

// if the answer is no then return to menu else ask for next
// number

if (ascii_char == 'n')
return;

else goto loop1;

}

// function to convert a keyboard character to its octal
// and then decimal value.

void key_value ()

{

char ascii_char;
char crlf_char;
char next_digit;
int count;
int oct_num;
int dec_num;
int dec_count;
int con_num[4] = {0,0,0,0};

// prompt the operator for the keyboard character

loop1: for (count = 0; count <= 3; ++count)
con_num[count] = 0;

cout << "\n\n Enter the Keyboard Character: ";

ascii_char = cin.get ();
crlf_char = cin.get (); // get that crlf

// convert keyboard character to decimal and let it print

cout << "\n\n Keyboard Character: '";
cout << ascii_char;
cout << "' ";
cout << "is ";

//convert character to octal

count = 0;

do
{
++count;
con_num[count] = (ascii_char % 8);
ascii_char = (ascii_char / 8);
}
while (ascii_char != 0);

//get the digits from the buffer and print the octal number

do
{
next_digit = (con_num[count] + '0');
cout << next_digit;
--count;
}
while (count > 0);

cout << " in octal and ";

// convert octal number to decimal and let it print

dec_num = 0;
dec_count = 1;
count = 1;

do
{
oct_num = (con_num[count] & 1);
if (oct_num == 1)
dec_num = (dec_num + dec_count);
dec_count = (dec_count + dec_count);

oct_num = (con_num[count] & 2);
if (oct_num == 2)
dec_num = (dec_num + dec_count);
dec_count = (dec_count + dec_count);

oct_num = (con_num[count] & 4);
if (oct_num == 4)
dec_num = (dec_num + dec_count);
dec_count = (dec_count + dec_count);

++count;
}
while (count <= 3);

cout << dec_num;

cout << " in decimal.";

// prompt the operator for a 'y' or a 'n'

cout << "\n\n Try another character (y or n): ";

// if the answer is no return to the menu else ask for
// another keyboard character

ascii_char = cin.get ();
crlf_char = cin.get (); // get that crlf

if (ascii_char == 'n')
return;

goto loop1;

}

//

function to add, substract, multiply, or divide

void arith_value ()

{

char ascii_char;
char crlf_char;
float dec_numa;
float dec_numb;
float dec_num;

// get either a + b, a - b, a * b, or a / b from the operator

loop1: cout << "\n\n Arithmetic operations\n";
cout << " Examples: '8+2, 9-2, 7*7, or 8/2': ";

cin >> dec_numa >> ascii_char >> dec_numb;

// if it was a + b then add and thats the number a + b = c

if (ascii_char == '+')

{
dec_num = (dec_numa + dec_numb);
cout << "\n\n The answer is: ";
cout << dec_numa;
cout << " " << ascii_char << " ";
cout << dec_numb;
cout << " = ";
cout << dec_num;
}

// if it was a - b then subtract and thats the number a - b = c

if (ascii_char == '-')
{
dec_num = (dec_numa - dec_numb);
cout << "\n\n The answer is: ";
cout << dec_numa;
cout << " " << ascii_char << " ";
cout << dec_numb;
cout << " = ";
cout << dec_num;
}

// if it was a * b then multiply and thats the number a * b = c

if (ascii_char == '*')
{
dec_num = (dec_numa * dec_numb);
cout << "\n\n The answer is: ";
cout << dec_numa;
cout << " " << ascii_char << " ";
cout << dec_numb;
cout << " = ";
cout << dec_num;
}

// if it was a / b then divide and thats the number a / b = c

if (ascii_char == '/')
{
dec_num = (dec_numa / dec_numb);
cout << "\n\n The answer is: ";
cout << dec_numa;
cout << " " << ascii_char << " ";
cout << dec_numb;
cout << " = ";
cout << dec_num;
}

cout << "\n\n Try some more arithmatic 'y or n': ";

crlf_char = cin.get (); // get that crlf
ascii_char = cin.get ();

// if the answer is no then return to menu else ask for next
// number

if (ascii_char == 'n')
return;

else goto loop1;

}
cin.get ();

// if the answer is no return to menu else ask for another
// number

if (ascii_char == 'n')
return;

else goto loop1;

}

// This routine will convert a hex value to decimal

void chex_dec ()

{

char ascii_char;
char hex_buf[11] = {'0','0','0','0','0','0','0','0','0','0','0'};
char crlf_char;
int dec_count;
int index;
long int dec_value;

// prompt the operator to enter the hex number. the hex
// characters are then stored in an a character buffer until
// the numbers are terminated with a crlf.

loop1: cout << "\n\n Enter hex number: ";

index = 0;

do
{
++index;
ascii_char = cin.get ();
if (ascii_char <= '9')
hex_buf[index] = ascii_char - '0';
else hex_buf[index] = ((ascii_char - '0') - 7);
}
while (ascii_char != '\n');

dec_count = 1;
dec_value = 0;


// we are going to figure this out in binary. mask each bit,
// starting at the low order bit and calulate the decimal
// number. if the bit is there, add in the decimal count for
// that position or update the decimal count for the next
// binary postion.

do
{

--index; // trash crlf in buffer

// get the ascii character out of the buffer and
// calculate

if (hex_buf[index] != 0)
dec_value = (dec_value + (hex_buf[index] * dec_count));

dec_count = (dec_count * 16);

}

// the end of the buffer contains a crlf

while (index >= 2); //Last thing in the buffer is \n

cout << "\n The answer is: " << dec_value;

cout << "\n\n Try another number 'y or n': ";

// if the answer is no return to menu else ask for another
// number

ascii_char = cin.get ();
crlf_char = cin.get (); // get that crlf

if (ascii_char == 'n')
return;

else goto loop1;

}

// function to convert decimal to hex

void cdec_hex ()

{

char crlf_char;
char next_digit;
char ascii_char;
int count;
long int dec_num;
int con_num[10] = {0,0,0,0,0,0,0,0,0,0};

// get the decimal number from the operator and save it in a
// decimal value

loop1: cout << "\n\n Enter decimal number: ";

cin >> dec_num;

cout << "\n ";
cout << dec_num;
cout << " in decimal is ";

count= 0;

// each octal digit is the remainder of the base divided by
//the base these are saved in a buffer for calculation to
// an ascii character

do
{
++count;
con_num[count] = (dec_num % 16);
dec_num = (dec_num / 16);
}
while (dec_num != 0);

// get the digit from the buffer and make the ascii character

do
{
if (con_num[count] > 9)
next_digit = (con_num[count] + '0' + 7);
else
next_digit = (con_num[count] + '0');

cout << next_digit;
--count;
}
while (count != 0);

cout << " in hex.";

cout << "\n\n Try another number (y or n«: ";

crlf_char = cin.get (); // get that crlf
ascii_cha) = cin.get ();

// if the answer is no return to menu else ask for another
// number

if (ascii_char == 'n')
return;

else goto loop1;

}


// calculate the absolute value of a decimal number. if the
// number is less than 0 then negate the number.

double absolute_value(float func1,float func2,float func3)
{

double func_num;

func_num = (func1 * func2 - func3);

if (func_num < 0)
func_num = -func_num;
func_num = func_num;

return (func_num);

}

// function to find the square root of a number

void sq_root ()

{

char ascii_char;
char crlf_char;
int index;
double epsilon;
float guess;
float dec_num;

// get the decimal number from the operator and save it.
// if guess squared minus the number is greater than or
// equal to one then thats the number else set guess to
// the nmuber divided by guess divided by 2 guess again.

loop1: guess = 1.0; // initialize some variables
epsilon = .00001;
index = 0;

cout << "\n\n Input decimal number: ";

cin >> dec_num;

if (dec_num < 0)
{
cout << "Cannot square root a negative number";
goto loop1;
}

while ((absolute_value(guess,guess,dec_num) >= epsilon) && (index <= 20))
{
guess = (((dec_num / guess) + guess) / 2.0);
index = index + 1;
}

cout << "\n Square root is: " << guess;
cout << "\n\n Try another number (y or n): ";

crlf_char = cin.get (); // get that crlf
ascii_char = cin.get ();

// if the answer is no then return to menu else ask for next
// number

if (ascii_char == 'n')
return;

else goto loop1;

}

// function to convert a keyboard character to its octal
// and then decimal value.

void key_value ()

{

char ascii_char;
char crlf_char;
char next_digit;
int count;
int oct_num;
int dec_num;
int dec_count;
int con_num[4] = {0,0,0,0};

// prompt the operator for the keyboard character

loop1: for (count = 0; count <= 3; ++count)
con_num[count] = 0;

cout << "\n\n Enter the Keyboard Character: ";

ascii_char = cin.get ();
crlf_char = cin.get (); // get that crlf

// convert keyboard character to decimal and let it print

cout << "\n\n Keyboard Character: '";
cout << ascii_char;
cout << "' ";
cout << "is ";

//convert character to octal

count = 0;

do
{
++count;
con_num[count] = (ascii_char % 8);
ascii_char = (ascii_char / 8);
}
while (ascii_char != 0);

//get the digits from the buffer and print the octal number

do
{
next_digit = (con_num[count] + '0');
cout << next_digit;
--count;
}
while (count > 0);

cout << " in octal and ";

// convert octal number to decimal and let it print

dec_num = 0;
dec_count = 1;
count = 1;

do
{
oct_num = (con_num[count] & 1);
if (oct_num == 1)
dec_num = (dec_num + dec_count);
dec_count = (dec_count + dec_count);

oct_num = (con_num[count] & 2);
if (oct_num == 2)
dec_num = (dec_num + dec_count);
dec_count = (dec_count + dec_count);

oct_num = (con_num[count] & 4);
if (oct_num == 4)
dec_num = (dec_num + dec_count);
dec_count = (dec_count + dec_count);

++count;
}
while (count <= 3);

cout << dec_num;

cout << " in decimal.";

// prompt the operator for a 'y' or a 'n'

cout << "\n\n Try another character (y or n): ";

// if the answer is no return to the menu else ask for
// another keyboard character

ascii_char = cin.get ();
crlf_char = cin.get (); // get that crlf

if (ascii_char == 'n')
return;

goto loop1;

}

// function to add, substract, multiply, or divide

void arith_value ()

{

char ascii_char;
char crlf_char;
float dec_numa;
float dec_numb;
float dec_num;

// get either a + b, a - b, a * b, or a / b from the operator

loop1: cout << "\n\n Arithmetic operations\n";
cout << " Examples: '8+2, 9-2, 7*7, or 8/2': ";

cin >> dec_numa >> scii_char >> dec_numb;

// if it was a + b then add and thats the number a + b = c

if (ascii_char == '+')

{
dec_num = (dec_numa + dec_numb);
cout << "\n\n The answer is: ";
cout << dec_numa;
cout << " " << ascii_char << " ";
cout << dec_numb;
cout << " = ";
cout << dec_num;
}

// if it was a - b then subtract and thats the number a - b = c

if (ascii_char == '-')
{
dec_num = (dec_numa - dec_numb);
cout << "\n\n The answer is: ";
cout << dec_numa;
cout << " " << ascii_char << " ";
cout << dec_numb;
cout << " = ";
cout << dec_num;
}

// if it was a * b then multiply and thats the number a * b = c

if (ascii_char == '*')
{
dec_num = (dec_numa * dec_numb);
cout << "\n\n The answer is: ";
cout << dec_numa;
cout << " " << ascii_char << " ";
cout << dec_numb;
cout << " = ";
cout << dec_num;
}

// if it was a / b then divide and thats the number a / b = c

if (ascii_char == '/')
{
dec_num = (dec_numa / dec_numb);
cout << "\n\n The answer is: ";
cout << dec_numa;
cout << " " << ascii_char << " ";
cout << dec_numb;
cout << " = ";
cout << dec_num;
}

cout << "\n\n Try some more arithmatic 'y or n': ";

crlf_char = cin.get (); // get that crlf
ascii_char = cin.get ();

// if the answer is no then return to menu else ask for next
// number

if (ascii_char == 'n')
return;

else goto loop1;

}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
-Üs Alma
#include <stdio.h>
#include <conio.h>

int Rintegerpower( int , int );
void integerpower( int , int );

main()
{
int a,b;

printf("Sayilari giriniz, 2.sayi 1. sayidan kucuk olarak giriniz : ");
scanf("%d%d",&a,&b);

while( (a + b) != 0 ) {

printf("Recursive ile bulunan deger : %d\n", Rintegerpower(a,b));
integerpower(a,b);

printf("\nSayilari giriniz : ");
scanf("%d%d",&a,&b);
}

getch();
return 0;
}

int Rintegerpower ( int a , int b){

if ( b==0 )
return 1;
else if ( b == 1 )
return a;
else
return a * Rintegerpower( a , b - 1 );

}

void integerpower ( int a , int b ){
int i,sonuc=1;

for (i = 1 ; i <= b ; i++ ){
sonuc *=a;
}

printf("For dongusu ile bulunan deger : %d\n",sonuc);

}


/* Bu program üs alma işlemini recursive ve for döngülü 2 fonksiyon kullanarak gerçekliyor.*/
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
-Matris Multiplication
/*
Name: Cem KO€
Email: cemkoc2576@hotmail.com
Description: Performs matrix multiplication.
*/

#include<stdio.h>
#include<conio.h>
void main()
{
int mat1[2][2],mat2[2][2],mat3[2][2],i,j,k;
printf("************A program to find the multiplication of the given matrices***********\n\n");
printf("************Enter the value for the 1st matrix************\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("\nEnter the value for %d row,%d column:",i+1,j+1);
scanf("%d",&mat1[j]);
}
}
printf("\n************Enter the value for the 2nd matrix************\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("\nEnter the value for %d row,%d column:",i+1,j+1);
scanf("%d",&mat2[j]);
}
}
printf("\n****************************The given matrices are*****************************\n\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d\t",mat1[j]);
}
printf("\n");
}
printf("\n\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d\t",mat2[j]);
}
printf("\n");
}
printf("\n****************************The multiplication of the matrices is*************\n\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
mat3[j]=0;
for(k=0;k<2;k++)
{
mat3[j]=mat3[j]+(mat1[k]*mat2[k][j]);
}
}
}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d\t",mat3[j]);
}
printf("\n");
}

getch();
getch();
}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
-Kök Bulma
/*
Name: Cem Koç
Category: Mathematics
Description: To find roots(Real and complex) of a third order equation
*/

#include<conio.h>
#include<stdio.h>
#include<math.h>

void main(void)
{
clrscr();
float a,b,c,d,i,j,k,x1,x2,l,r,z,fxl,u,fxr;
float xl = -90.0;
float xu = 100.0;
float xr;
printf("Enter a, b, c & d:");
scanf("%f, %f, %f, %f", &a, &b, &c,&d);
for(i=0;i<1000;i++)
{
fxl = (a*pow(xl,3)) + (b*pow(xl,2) ) + (c*xl) + d;
xr = (xl + xu)/2;
fxr = (a*pow(xr,3)) + (b*pow(xr,2) ) + (c*xr) + d;
if((fxl*fxr)<0)
xu = xr;
else
xl = xr;
if(fxr<0.000001 && fxr>-0.000001)
{
printf("The three roots are as follows: -\n");
printf("x1 = %.2f\n", xr);
break;
}
}
i = b + (xr*a);
j = c + (xr*i);
k = i*i - (4*a*j);
if( k >= 0)
{
x1 = (-i + sqrt(k))/(2*a);
x2 = (-i - sqrt(k))/(2*a);
printf("x2 = %.2f\n",x1);
printf("x3 = %.2f",x2);
}
else
{
l = -k;
r = -i/(2*a);
z = (sqrt(l))/(2*a);
printf("x2 = %.2f + j%.2f\n", r,z);
printf("x3 = %.2f - j%.2f\n", r,z);
}
getch();
}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
-Pisagor üçgeninin kenarlarını bulan ve text dosyasına yazdıran bir program
#include <stdio.h>
#define MAX 1000

main()
{
FILE *pisagor;
int a,b,c;

if ((pisagor=fopen("pisagor.txt","w"))==NULL) /* write modunda pisagor.txt adında bir dosya açılmış. Eğer bu dosyanın içeriği NULL is yani boş ise bu dosya oluşturulamamış demektir.*/
printf("Dosya Acilamadi.\n");
else{
for (a=1;a<=MAX;a++) /* bütün kenarların uzunluğu MAX'a kadar olmak zorunda */
for (b=1;b<=MAX;b++)
for (c=1;c<=MAX;c++)
if (a*a+b*b==c*c){ /* pisagor formülü*/
fprintf(pisagor,"%5d%5d%5d\n",a,b,c);/*fprintf komutuyla text dostasına yazdırılması*/
}

}

fclose(pisagor); /* pisagor dosyası kapatılmış */
return 0;
}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
-Pisagor üçgeninin kenarlarını bulan ve text dosyasına yazdıran bir program
#include <stdio.h>
#define MAX 1000

main()
{
FILE *pisagor;
int a,b,c;

if ((pisagor=fopen("pisagor.txt","w"))==NULL) /* write modunda pisagor.txt adında bir dosya açılmış. Eğer bu dosyanın içeriği NULL is yani boş ise bu dosya oluşturulamamış demektir.*/
printf("Dosya Acilamadi.\n");
else{
for (a=1;a<=MAX;a++) /* bütün kenarların uzunluğu MAX'a kadar olmak zorunda */
for (b=1;b<=MAX;b++)
for (c=1;c<=MAX;c++)
if (a*a+b*b==c*c){ /* pisagor formülü*/
fprintf(pisagor,"%5d%5d%5d\n",a,b,c);/*fprintf komutuyla text dostasına yazdırılması*/
}

}

fclose(pisagor); /* pisagor dosyası kapatılmış */
return 0;
}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
using System;
using System.Runtime.InteropServices;

namespace Bippp
{
class Bibip
{
[DllImport("kernel32.dll")]
public static extern bool Beep(int frequency, int duration);

static void Main(string[] args)
{
Random rastgele = new Random();

for (int i = 0; i < 100000; i++)
{
Beep(rastgele.Next(5000), rastgele.Next(60,80));

}
}
}
}

__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
java da yazilmis, combinasyonlari buluyor, mesela 16 rakam icinden 14 tane secilecek, combinasyonlar.. reccursion la yapilmis. bayaa oldu yapali, yani ayni yolla daha hizli ve guzel olabilirdi.

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Combination extends JFrame implements ActionListener{
private Container c=getContentPane();
private JButton bt=new JButton("Show");
private JTextArea txt=new JTextArea();
private JScrollPane sc=new JScrollPane(txt);
private JTextField text1=new JTextField("7");
private JTextField text2=new JTextField("6");
private JLabel lb=new JLabel();
private int num=0,diff=0,counter=0,digit=0,lim=0;
private String output="",number="",numberpre="";
public Combination(){
super("Combination");
c.setLayout(null);
bt.setSize(new Dimension(150,50));
bt.setLocation(50,200);
bt.setVisible(true);
text1.setSize(new Dimension(150,30));
text1.setLocation(50,50);
text2.setSize(new Dimension(150,30));
text2.setLocation(50,120);
sc.setSize(new Dimension(200,300));
sc.setLocation(50,270);
lb.setSize(new Dimension(150,20));
lb.setLocation(300,270);
c.add(bt);
c.add(sc);
c.add(text1);
c.add(text2);
c.add(lb);
bt.addActionListener(this);
setSize(400,650);
setVisible(true);
}
public void actionPerformed(ActionEvent e){
try{
int a=Integer.parseInt(text1.getText());
lim=Integer.parseInt(text2.getText());
if(a<=0)
JOptionPane.showMessageDialog(null,"Enter Pozitive Integer");
else if(lim>a)
JOptionPane.showMessageDialog(null,"Enter Integer Equal or Smaller Than First Number");
else{
output="";
counter=0;
digit=0;
num=a;
diff=num-lim;
find(1);
txt.setText(output);
lb.setText(""+counter);
}
}catch(Exception x){
txt.setText("Error");
}
}
private void find(int a){
String numberthis="";
numberthis=number;
for(int i=a;i<=diff+a;i++){
if(i<=num){
number=numberthis+i+" ";
digit++;
if(digit==lim){
output+=number+"\n";
counter++;
number=numberthis;
digit--;
}else{
find(i+1);
digit--;
}
}
}
number=numberthis;
}
public static void main(String[] args){
Combination com=new Combination();
com.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) ;
}
}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
bu da bi reccursion odeviydi, rastgele bi sekil ciziyor, ve icine tiklaninca icini dolduruyor. iki isi de reccursion la yapiyor. java da yazildi, iki class var.



import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class Painter extends JFrame implements MouseListener{
public static final int DRAW_SHAPE=0; //task types of thread
public static final int FILL=1;
private int task; //task of thread
private JButton button=new JButton("generate new shape");
private JTextField label=new JTextField(" ");
public Square s[][]=new Square[100][100]; //all small units in the area
public int x=0,y=0;
private Random rnd=new Random();
private static boolean clicked=false,started=false,closed=true;
private MyThread th=new MyThread();
public Painter(){
super("Painter");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setLayout(null);
label.setSize(250,30);
label.setLocation(230,585);
label.setEnabled(false);
button.setSize(200,30);
button.setLocation(230,30);
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
newShape();
}}
);
getContentPane().add(button);
getContentPane().add(label);
setSize(700,700);
setLocation(70,50);
this.addMouseListener(this);
show();
}
public static void main(String[] args){
Painter p=new Painter();
}
/* all paintings (drawing and filling square) is done by repaint method */
public void paint(Graphics g){
button.setEnabled(false);
if(!started){ //if program has just started (there isn't any Square)
for(int i=0;i<100;i++)
for(int j=0;j<100;j++)
s[j]=new Square(g,i,j);
started=true;
task=DRAW_SHAPE;
th.start(); //thread draws a random shape
}else
if(task==DRAW_SHAPE){ //if thread is drawing shape
for(int i=0;i<100;i++) //reset colors and checked indicators
for(int j=0;j<100;j++){
s[j].setColor(g,Color.white);
s[j].setChecked(false);
}
draw(g); //draws random shape
}else //if thread's task is to fill squares...
th.fill(g,x,y); //fill squares
button.setEnabled(true);
}
/* this method generates 4 initial random points from the area. it selects
them from top, down right and left. then, another method (drawRnd)
connects these 4 points randomly with an recursive structure. */
private void draw(Graphics g){
//generate coordinates of 4 points randomly
int a[]={rnd.nextInt(25),rnd.nextInt(25)+37,rnd.nextInt(2 5)+37,
rnd.nextInt(25),rnd.nextInt(25)+75,rnd.nextInt(25) +37,
rnd.nextInt(25)+37,rnd.nextInt(25)+75};
for(int i=0;i<8;i=i+2)
s[a][a[i+1]].setColor(g,Color.red);

//each of these draws a random line.
th.drawRnd(g,a[0],a[1],a[2],a[3]);
th.drawRnd(g,a[2],a[3],a[4],a[5]);
th.drawRnd(g,a[4],a[5],a[6],a[7]);
th.drawRnd(g,a[6],a[7],a[0],a[1]);
}

//this method checks whether user clicked outside the closed area or not
private boolean check(int x,int y){
//if user has clicked outside white area...
if((x<100)||(x>100+Square.W*100)||(y<100)||(y>100+ Square.W*100)){
label.setText("ERROR: Outside Bounds");
label.setVisible(true);
clicked=false;
return false;
}else{
//check if clicked on a square of shape. if so, continue drawing
if(s[(x-100)/Square.W][(y-100)/Square.W].getColor()==Color.red){
clicked=false;
return false;
}
for(int i=0;i<100;i++)
for(int j=0;j<100;j++)
s[j].setChecked(false);
closed=true;
//after calling this method closed variable will be true or false
check2((x-100)/Square.W,(y-100)/Square.W);
if(!closed){ //if user clicked outside the shape
label.setText("ERROR: Outside Closed Area");
label.setVisible(true);
clicked=false;
return false;
}
}
return true;
}

/* this method is similar with fill method. in oder to paint squares, this
sets a boolean of each object and checks it again. */
private void check2(int x,int y){
if(closed){ //if point is outside, do nothing
//check whether square exist or not
if(!((x<0)||(x>99)||(y<0)||(y>99))){
if(!s[x][y].isChecked()){
s[x][y].setChecked(true);
check2(x+1,y);
check2(x-1,y);
check2(x,y+1);
check2(x,y-1);
}
}else //if square not exists, the point clicked is outside area
closed=false;
}
}

/* when button is clicked, this method is called. this metdod stops the
MyThread object, creates new object and starts it */
private void newShape(){
label.setVisible(false);
clicked=false;
th=new MyThread();
task=DRAW_SHAPE;
th.start();
}
public void mouseReleased(java.awt.event.MouseEvent p1) {}
public void mouseEntered(java.awt.event.MouseEvent p1) {}
public void mouseClicked(java.awt.event.MouseEvent p1) {
if(!clicked){
label.setVisible(false);
clicked=true;
//check the clicked point
boolean free=check(p1.getX(),p1.getY());
x=(p1.getX()-100)/Square.W;
y=(p1.getY()-100)/Square.W;
if(free){ //if point is in the area, change task and retart thread
task=FILL;
th=new MyThread();
th.start();
}
}
}
public void mousePressed(java.awt.event.MouseEvent p1) {}
public void mouseExited(java.awt.event.MouseEvent p1) {}

private class MyThread extends Thread{
public void run(){
repaint();
}

/* this method fills inside the closed area with red color. in each,
methods sleeps 1 milisecond and continues */
public void fill(Graphics g,int x,int y){
try{
if(!(s[x][y].getColor()==Color.red)){
s[x][y].setColor(g,Color.red);
Thread.sleep(1);
fill(g,x+1,y);
fill(g,x-1,y);
fill(g,x,y+1);
fill(g,x,y-1);
}
}catch(Exception e){
System.out.println(e);
}
}

/* this method connects two points randomly whose coordinetes are given
as parameters. in each step, methods find a random point between
points and divides it's own work in to two methods. each method
after that finds a random point between the previous point and new
point. it continues until. there is no space between points.
eacs method also sleeps 10 ms */
private void drawRnd(Graphics g,int x1,int y1,int x2,int y2){
try{
int xRnd,yRnd,smallX,smallY;
smallX=(x1<x2)? x1:x2;
smallY=(y1<y2)? y1:y2;
do{ //generate random coordinates between the given coordinates
xRnd=rnd.nextInt(Math.abs(x2-x1)+1)+smallX;
yRnd=rnd.nextInt(Math.abs(y2-y1)+1)+smallY;
}while((xRnd==x1&&yRnd==y1)||((xRnd==x2)&&(yRnd==y 2)));
Thread.sleep(10);
s[xRnd][yRnd].setColor(g,Color.red);

/* check if there is space between the point and new point
generated. if no, dont call any more methods */
if(!((xRnd==x1&&Math.abs(yRnd-y1)==1)||
(Math.abs(xRnd-x1)==1&&y1==yRnd)))
drawRnd(g,x1,y1,xRnd,yRnd);
if(!(((xRnd==x2)&&Math.abs(y2-yRnd)==1)||
(Math.abs(x2-xRnd)==1&&y2==yRnd)))
drawRnd(g,xRnd,yRnd,x2,y2);
}


catch(Exception x){
System.out.println(x);
}
}
}
}



import javax.swing.*;
import java.awt.*;
/* all squares in the area are objects of class. in the area there are
10.000 objects of this class. each objects keeps its coordinates,
color, vb. and draws small squares to their piece */
public class Square{
public static final int W=5;
private int x=0;
private int y=0;
private Color color=Color.white;
private boolean checked=false;
public Square(Graphics g,int x,int y){
this.x=x;
this.y=y;
g.setColor(Color.white);
g.fillRect(100+x*W,100+y*W,W,W);
}
public void setColor(Graphics g,Color c){
g.setColor(c);
g.fillRect(100+x*W,100+y*W,W,W);
color=c;
}
public int getX(){
return x;
}
public int getY(){
return y;
}
public Color getColor(){
return color;
}
public void setChecked(boolean b){
checked=b;
}
public boolean isChecked(){
return checked||(color==Color.red);
}
}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Bir salt metin dosyasında alt alta yazılı reel sayıları bir diziye atayarak bu dizideki sayılar üzerinde şu işlemleri gerçekleştiren bir program yazınız. Aşağıdaki her şık için özel bir fonksiyon geliştiriniz.


--Sayıların ortalama değerinin hesaplanması:


--Sayıların örnek standart sapmasının hesaplanması:


Örnek standart sapması formülüyle hesaplanır.

--Sayıların minimum ve maksimumunun hesaplanması

--Sayıların küçükten büyüğe sıraya sokularak sirali.txt adlı bir salt metin dosyasına yazılması:

Örnek:
Okunan dosya (data.txt) Yazılan dosya (sirali.txt)

15.1 13.5
92.1 15.1
32.5 21.6
21.6 32.5
58.7 58.7
66.2 66.2
13.5 67.5
76.9 72.3
67.5 76.9
72.3 92.1

--Verilen bir değer aralığındaki tüm sayıların bulunup sıralanarak ekrana yazılması:

Az evvelki örnekte değer aralığı [20.0, 60.0] olsun.
Bu durumda ekran çıktısı:

21.6
32.5
58.7

İpucu: Salt metin dosyasının okunması işlemi aşağıdaki program tarafından yapılmaktadır. Bu programı geliştireceğiniz programa ekleyebilirsiniz.

#include <stdio.h>

#define N 500 /* maks dizi boyutu*/

void main()
{
FILE *di;
float dizi[N];
int i,diziboyu;
printf("sayilar data.txt dosyasi icinde olmalidir\n");
printf(" epi v1.0 C derleyicisi kullaniliyorsa data.txt, TurboC dizini icinde yer almalidir\n");
if ( (di=fopen("data.txt","rt")) == NULL){
printf("dosya acilmasinda hata!\n");
exit(0);
}
printf("dosyadaki sayi adedi:");
scanf("%d", &diziboyu);
for(i=0; i<diziboyu;i++)
fscanf(di,"%f", &dizi);
fclose(di);
for(i=0; i<diziboyu;i++)
printf("sayi:%f\n", dizi);
}


--------------------------------------------------------------------
--------------------------------------------------------------------
VERİLEN PROJE NİN kodları :
#include "stdio.h"
#include "stdlib.h"
#include "math.h"
#define N 500 /* maks dizi boyutu*/

int fonksyon_ort(float dizi1[N]);
int fonksyon_sapma(float dizi1[N]);
int fonksyon_maxmin(float dizi1[N]);
float fonksyon_siralama(float dizi1[N]);
int fonksyon_aralik(float dizi1[N]);
int diziboyutu;

void main()
{
FILE *di;
float dizi[N];
int i,diziboyu;
char choose;
printf("sayilar data.txt dosyasi icinde olmalidir\n");
printf(" epi v1.0 C derleyicisi kullaniliyorsa data.txt, TurboC dizini icinde yer almalidir\n");
if ( (di=fopen("data.txt","rt")) == NULL){
printf("dosya acilmasinda hata!\n");
exit(0);
}
printf("dosyadaki sayi adedi:");
scanf("%d", &diziboyu);
for(i=0; i<diziboyu;i++)
fscanf(di,"%f", &dizi);
fclose(di);
for(i=0; i<diziboyu;i++)
printf("sayi %d :%f\n",i+1,dizi);
diziboyutu=diziboyu;
printf("\n lutfen seciminizi yapiniz...\n");
printf("\n a)ortalama bulma\n b)standart sapma hesaplama\n c)sayilar icinde max/min hesabi");
printf("\n d)tanimlanan deger araliginda sayi bulma\n e)sayilari siralama \n f)HEPSI BIRDEN..");
choose=getch();
switch(choose)
{
case 'a' :
printf("\n\n\n");
fonksyon_ort(dizi);
break;
case 'b' :
printf("\n\n\n");
foksyon_sapma(dizi);
break;
case 'c' :
printf("\n\n\n");
fonksyon_maxmin(dizi);
break;
case 'd' :
printf("\n\n\n");
fonksyon_aralik(dizi);
break;
case 'e' :
printf("\n\n\n");
fonksyon_siralama(dizi);
break;
case 'f' :
printf("\n\n\n");
fonksyon_ort(dizi);
foksyon_sapma(dizi);
fonksyon_maxmin(dizi);
fonksyon_aralik(dizi);
fonksyon_siralama(dizi);
}



}


fonksyon_ort(float dizi1[N])

{
int i;
float ort=0;
for(i=0;i<diziboyutu;i++)
ort+=dizi1;
ort=ort/diziboyutu;
printf("a)sayilarin ortalamalari =%f\n",ort);
return 0;
}


foksyon_sapma(float dizi1[N])

{
int i,j;
float deger1=0,deger2=0,deger3=0,sonuc;
for(i=0;i<diziboyutu;i++)
deger1+=dizi1*dizi1;
deger1=deger1*diziboyutu;
for(j=0;j<diziboyutu;j++)
deger2+=dizi1;
deger2=deger2*deger2;
deger3=diziboyutu*(diziboyutu-1);
sonuc=sqrt((deger1-deger2)/deger3);
printf("b)sayilarin standart sapmasi =%f\n",sonuc);
return 0;
}



fonksyon_maxmin(float dizi1[N])

{
int i;
float max,min;
max=dizi1[0];
for(i=0;i<diziboyutu;i++)
{
if(dizi1>max)
max=dizi1;
}
printf("c)en buyuk sayi(MAX) =%f\n",max);
min=dizi1[0];
for(i=0;i<diziboyutu;i++)
{
if(min>dizi1)
min=dizi1;
}
printf(" en kucuk sayi(MIN) =%f\n",min);
return 0;
}



int fonksyon_aralik(float dizi1[N])

{
int i,j=0,k;
float deger1,deger2,sonuc[N],ara;
printf("\nd) sikki icin istediginiz araliklari giriniz..\n");
printf("\ndeger1=");
scanf("%f",&deger1);
printf("\ndeger2=");
scanf("%f",&deger2);
if(deger1<deger2)
{
for(i=0;i<diziboyutu;i++)
if(dizi1>=deger1&&dizi1<=deger2)
{
sonuc[j]=dizi1;
j++;
}
}
if(deger1>deger2);
{
for(i=0;i<diziboyutu;i++)
if(dizi1>deger2&&dizi1<deger1)
{
sonuc[j]=dizi1;
j++;
}
}
if(deger1==deger2)
{
printf("bu iki sayi esit !!!\n");
}
/*for(i=0;i<j+1;i++)
for(k=0;k<j+2;k++)
if(sonuc>sonuc[i+1])
{
ara=sonuc;
sonuc=sonuc[i+1];
sonuc[i+1]=ara;
}*/
printf("d)girilen aralikta bulunan sayilar =");

for(i=0;i<j-1;i++)
{
printf("(%f)\n",sonuc);
printf(" ");
}
return 0;
}




float fonksyon_siralama(float dizi1[N])

{
FILE *di;
int i,j,k;
float ara;
for(k=0;k<diziboyutu;k++)
for(i=0;i<diziboyutu;i++)
if(dizi1>dizi1[i+1])
{
ara=dizi1;
dizi1=dizi1[i+1];
dizi1[i+1]=ara;
}
printf("\ne)siralama kucukten buyuge\n");
for(j=1;j<diziboyutu+1;j++)
printf("%f\n",dizi1[j]);
if((di=fopen("sirali.txt","wt"))==NULL)
exit(0);
fwrite(dizi1,sizeof(float),10,di);
fclose(di);
printf("\nsirali.txt dosyasi klasorde olusturuldu...\n");
return 0;
}
-------------------------------------------
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Alarmlı Saat


Form'a 3 tane label ekleyin yan yana olmasi kafanizin karişmasini engeller,2 tane text box (alarmi kurdugunuz dakika ve saat degerini belitmek için), timer kontrolü,alarmýn kurdugunuzu belirmek için de birtane command butonu ekleyin.
**************

Option Explicit
Dim a As Integer ' program boyunca kullanilacak a degiskeni
Dim b As Integer ' program boyunca kullanilacak b degiskeni
Private Sub Command1_Click()
a = Val(Text1.Text) ' text1 degeri (a) ya ataniyor
b = Val(Text2.Text) ' text2 degeri (b) ye ataniyor
End Sub

Private Sub Form_Load()
Dim zaman, dakika
Timer1.Enabled = True
Timer1.Interval = 1000 ' bu deger 1 saniyeye karsilik gelir
Form1.Caption = "Alarm V.01"
End Sub

Private Sub Text1_Click()
Text1.Text = ""
End Sub

Private Sub Text2_Click()
Text2.Text = ""
End Sub
Private Sub Timer1_Timer()
Dim zaman, saniye, dakika, saat
zaman = Time
saniye = Second(zaman)
dakika = Minute(zaman)
saat = Hour(zaman)
Label1.BackColor = QBColor(0)
Label1.ForeColor = QBColor(10)
Label1.FontSize = 20
Label1.Alignment = 2
Label1.Caption = saat
Label2.BackColor = QBColor(0)
Label2.ForeColor = QBColor(10)
Label2.FontSize = 20
Label2.Alignment = 2
Label2.Caption = dakika
Label3.BackColor = QBColor(0)
Label3.ForeColor = QBColor(10)
Label3.FontSize = 20
Label3.Alignment = 2
Label3.Caption = saniye
If saat = a Then
If dakika = b Then
Beep 'dakika degeri(label2), sizin kurdugunuz dakika degeri (text2) ile ayný oldugu müddetçe beep sesi alýrsýnýz(60 saniye)

End If
End If

End Sub​

PROGRAMLAMA HAYATTIR
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Dosya işlemlerinde output rset ve assign işlemleri (Delphi)

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

var
myfile:Textfile;
strInput:String;
begin
AssignFile(myfile,'myout.txt');
Reset(myfile);
Readln(myfile,strInput);
Closefile(myfile);
Label1.Caption:=strInput;

end;

end.

----------------

e.g.
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Process işlemlerinden SPN nin algoritması

/*-----------------------------------------------------------
| Shortest Process Next Scheduling Algorithms
|------------------------------------------------------------*/

#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
#include <stdio.h>
#include <math.h>
#define JobsNumber 4

struct JobStatus
{ char ActiveProcess;
int Time;
char Durumu[100];
};

struct JobsProperies
{ int ArrivalTime;
int CPU1;
int IO1;
int CPU2;
int IO2;
int CPU3;
};

struct JobsProperies Jobs[JobsNumber];
struct JobStatus Job[JobsNumber];


class ShortestProcessNext
{
private:
public:
void New()
{ int a,b,c,d,e,f;
int count;
FILE *dat;
dat=fopen("input.txt","r");
count=0;
while(fscanf(dat,"%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)!= EOF)
{
// printf("%d \t %d \t %d \t%d \t%d \t%d\n",a,b,c,d,e,f);
Jobs[count].ArrivalTime=a;
Jobs[count].CPU1=b;
Jobs[count].IO1=c;
Jobs[count].CPU2=d;
Jobs[count].IO2=e;
Jobs[count].CPU3=f;
count=count+1;

}
fclose(dat);
}

int FindMin()
{ int tmp;
int whichjob;
tmp=Jobs[0].ArrivalTime;
whichjob=0;
for (int i=1;i<JobsNumber;i++)
{
if (tmp>Jobs.ArrivalTime)
{tmp=Jobs.ArrivalTime;
whichjob=i;
}

}
return(whichjob);

}

int Read(int t)
{

int whichjob;
whichjob=0;
for (int i=1;i<JobsNumber;i++)
{


if (t==Jobs.ArrivalTime)
{
whichjob=i;
}

}

return(whichjob);

}

void Block(int job,int t,int j)
{ static refTime;

refTime=t+(j);
Job[job].Durumu[refTime]='B';
refTime++;
}

void Wait(int job,int t)
{ Job[job].Durumu[t]='W';
}

void Exit()
{
}
void Run()
{int t;
int StarJob;
int CPUs;
int BLK;
char wjob[JobsNumber];
int Wt;//wait job count
int read;
char std;
int CPUcnt;
char BLKDRM;
t=0;
CPUcnt=1;
StarJob=FindMin();
Job[StarJob].Time=t;
Job[StarJob].Durumu[t]='R';
Job[StarJob].ActiveProcess='R';
CPUs=Jobs[StarJob].CPU1;
BLK=Jobs[StarJob].IO1;
std='R';
t=1;
while (t<50)
{


gotoxy(11,9); cout<<0; gotoxy(59,9); cout<<50;
for (int i=0;i<JobsNumber;i++){
gotoxy(0,10+i);cout<<"Job"<<i+1;gotoxy(10+t,10+i); cout<<Job.Durumu[t-1];}
gotoxy(1,5);cout<<"Time is "<<t;



if (CPUcnt==CPUs)
{for(int i=0;i<BLK;i++)
{ Block(StarJob,t,i);
std='F';
Job[StarJob].ActiveProcess='B';}

}






for(int j=0;j<4;j++)
{gotoxy(7,10+j);cout<<Job[j].ActiveProcess;
//if (Job[j].ActiveProcess=='W')
{
Job[j].Durumu[t]=Job[j].ActiveProcess;
}

}


read=Read(t);

if (read==0)
{
Job[StarJob].Durumu[t]='R';
Job[StarJob].ActiveProcess='R';
for (int i=0;i<JobsNumber;i++)
{
if (wjob=='W')
{Wait (i,t);}
}

std='R';

}
else
{
if (std=='F')
{wjob[StarJob]=='W';
Job[StarJob].ActiveProcess='W';
StarJob=read;
CPUs=Jobs[StarJob].CPU1;
CPUcnt=1;
BLK=Jobs[StarJob].IO1;
Job[StarJob].Durumu[t]='R';
for (int i=0;i<JobsNumber;i++)
{
if (wjob=='W')
{Wait (i,t);}
}

std='R';

}
else if(std=='R')
{
wjob[read]='W';
Job[read].ActiveProcess='W';
for (int i=0;i<JobsNumber;i++)
{
if (wjob=='W')
{Wait (i,t);}
}
Job[StarJob].ActiveProcess='R';
Job[StarJob].Durumu[t]='R';
}

}





t++;
CPUcnt++;
}






}

};




main()
{ ShortestProcessNext SPN;
cout<<"\tShortest Process Next Scheduling Algorithms\n"<<endl;
cout<<"Getting New Jobs..."<<endl;
SPN.New(); //READ From File than
cout<<"ReadGetting New Jobs..."<<endl;
SPN.Run();





}


---------

s.o
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Girilen rakam dizisini okunus textine ceviren programdir. Visual C++ _int64 tipi yerine standard int kullanilabilir.


#include <string>
#include <iostream>
using namespace std;

string birOnYuz[][10] = { {"","bir ","iki ","uc ","dort ","bes ","alti ","yedi ","sekiz ","dokuz "},
{"","on ","yirmi ","otuz ","kirk ","elli ","atmis ","yetmis ","seksen ","doksan "},
{"","yuz ","iki yuz ","uc yuz ","dort yuz ","bes yuz ","alti yuz ","yedi yuz ","sekiz yuz ","dokuz yuz "} };

string bolum[] = { "","","","bin ",
"","","milyon ",
"","","milyar ",
"","","trilyon ",
"","","katrilyon ",
"","","kentilyon ",
"","","sentilyon " };

string rakamdanYaziya(unsigned __int64 rakam,unsigned int basamak = 0) {
if(rakam == 0) return std::string();
if(rakam == 1 && basamak == 3) return bolum[basamak];
return rakamdanYaziya(rakam / 10,basamak + 1)
+ birOnYuz[basamak % 3][rakam % 10]
+ (rakam % 1000 ? bolum[basamak] : string());
}

int main(int argc, char* argv[]) {
cout << rakamdanYaziya(12345678901234567890) << "TL borcunuz vardir." << endl;
return 0;
}

--------

C.O.
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
# include <iostream>
# include <string>
# include <iomanip>
# include <fstream>
using namespace std;
struct line
{
string name;
};
int num[4]={10,13,32,15};
const char *liste [4]={"Name","Surname","e-mail","Phone"};
# define max 200
int record (string);
int selection ();
int sort (string);
void sorting (line [],line [],int);
int main ()
{
string filename="gecici.txt";


cout<<" --------------------------------------------------------"<<endl;
cout<<" !!!!This program was developed by Bekir Selcuk Temel!!!!"<<endl;
cout<<" --------------------------------------------------------"<<endl;
cout<<endl;


cout<<" ---------------------------"<<endl;
cout<<" -Please select your choice-"<<endl;
cout<<" ---------------------------"<<endl;

cout<<endl;
cout<<endl;
cout<<" "<<setw(20)<<left<<"1.Open Record File"<<endl;
cout<<" "<<setw(20)<<left<<"2.Insert a Record"<<endl;
cout<<" "<<setw(20)<<left<<"3.Sorting"<<endl;
cout<<" "<<setw(20)<<left<<"4.Exit
"<<endl;
cout<<">";
int h;
cin>>h;
while (h!=0)
{
if (h==1)
{
system("cls");
string s;
cout<<"Enter file name to open"<<endl;
cin>>s;
filename=s;
system("cls");
cout<<"File opened"<<endl;
h=selection()+1;

}
if (h==2)
{
system("cls");
cout<<"Please give a contact [Name,Surname,email,Phone]"<<endl;
cout<<"Write 'exit' for exit!"<<endl;
h=record(filename);
}
if (h==3)
{
h=sort(filename)+1;
}
if (h==4)
{
cout << "
Thanx for using my program..
";
return 0;
}
}

return 0;
}
int record (string fname)
{
static int s=0;
s++;

ofstream fout(fname.c_str(),ios::app);
if (!fout)
{
cerr<<"File not opened"<<endl;
return 0;
}
if (s!=0)
{
fout<<endl;
}
string word;
int i=0;
cout<<">";
while (cin>>word)
{
if (word=="exit")
{
fout.close();

return selection();
}

fout<<setw(num)<<left<<word;
i++;
if (i==4)
{
break;
}
}
fout.close();
system("cls");
cout<<"Contact added yor file"<<endl;
record(fname);
return 0;
}
int selection ()
{
system("cls");

cout<<"Please select an action:
"<<endl;
cout<<" "<<setw(20)<<left<<"1.Insert a Record"<<endl;
cout<<" "<<setw(20)<<left<<"2.Sorting"<<endl;
cout<<" "<<setw(20)<<left<<"3.Exit
"<<endl;
cout<<">";
int s;
cin>>s;
return s;
}
int sort (string fname)
{
line t[max];
line k[max];
string dizi;
ifstream fin;
fin.open(fname.c_str());
if (!fin)
{
cerr<<"File not opened"<<endl;
return 0;
}
system("cls");
cout<<"Please select a column for sorting"<<endl;
cout<<" 1.Name"<<endl;
cout<<" 2.Surname"<<endl;
cout<<" 3.e-mail"<<endl;
cout<<" 4.telephone"<<endl;
cout<<">";
int m;
int count=0;
cin>>m;
int loc=0;
for (int i=1;i<m;i++)
{
loc=loc+num[i-1];
}
while (getline (fin,dizi)&&count<max)
{
t[count].name=dizi.substr(loc,num[m-1]);
k[count].name=dizi;
count++;
}
fin.close();
sorting (t,k,count);
ofstream fout;
fout.open (fname.c_str());
for (int j=0;j<count;j++)
{
fout<<k[j].name<<endl;
}
fout.close();
cout<<"Your contacts sorting according to "<<liste[m-1]<<endl;
return selection ();
}
void sorting (line a[],line b[],int c)
{
int s=0;
for (int i=0;i<c-1;i++)
{
for (int j=0;j<c-1;j++)
{
if (a[j].name>a[j+1].name)
{
line temp ;
temp.name=a[j].name;
a[j].name=a[j+1].name;
a[j+1].name=temp.name;
temp.name=b[j].name;
b[j].name=b[j+1].name;
b[j+1].name=temp.name;
s++;
}
}
}

}

---------
bsc
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Delphi: MD5 ile 128 bit şifreleme

Şifrelemek için MD_5(Mesaj) fonksiyonunu çağırın.


Kod:
unit MD5;

interface

type
  Dizi= Array of integer;

function MD_5(str: string): string;

implementation

function rhex(num: integer): string;
var
  str,hex_chr: string;
  j: integer;
begin
  hex_chr:='0123456789abcdef';
  str:=";
  for j:=0 to 3 do
    str:=str+hex_chr[((num shr (j*8+4)) and $F)+1]+hex_chr[((num shr (j*8)) and $F)+1];
  Result:=str;
end;

function str2blks_MD5(str: string): Dizi;
var
  nblk: integer;
  blks: Dizi;
  i: integer;
begin
  nblk:=((length(str)+8) shr 6)+1;
  SetLength(blks,nblk*16);
  for i:=0 to nblk*16-1 do blks[i]:=0;
  for i:=0 to length(str)-1 do
    blks[i shr 2]:=blks[i shr 2] or ((ord(str[i+1]) shl ((i mod 4)*8)));
  blks[i shr 2]:=blks[i shr 2] or ($80 shl ((i mod 4)*8));
  blks[nblk*16-2]:=length(str)*8;
  Result:=blks;
end;

function add(x,y: integer): integer;
var
  lsw,msw: integer;
begin
  lsw:=(x and $FFFF)+(y and $FFFF);
  msw:=(x shr 16)+(y shr 16)+(lsw shr 16);
  Result:=(msw shl 16) or (lsw and $FFFF);
end;

function rol(num,cnt: integer): integer;
begin
  Result:=(num shl cnt) or (num shr (32 - cnt));
end;

function cmn(q, a, b, x, s, t: integer): integer;
begin
  Result:= add(rol(add(add(a, q), add(x, t)), s), b);
end;

function ff(a, b, c, d, x, s, t: integer): integer;
Begin
  Result:= cmn((b and c) or ((not b) and d), a, b, x, s, t);
end;

function gg(a, b, c, d, x, s, t: integer): integer;
Begin
  Result:= cmn((b and d) or (c and (not d)), a, b, x, s, t);
end;

function hh(a, b, c, d, x, s, t: integer): integer;
Begin
  Result:= cmn(b xor c xor d, a, b, x, s, t);
end;

function ii(a, b, c, d, x, s, t: integer): integer;
Begin
  Result:= cmn(c xor (b or (not d)), a, b, x, s, t);
end;

function MD_5(str: string): string;
var
  x: dizi;
  a,b,c,d,olda,oldb,oldc,oldd: integer;
  i: integer;
begin
  x:= str2blks_MD5(str);
  a:= 1732584193;
  b:= -271733879;
  c:= -1732584194;
  d:= 271733878;

  i:=0;
  while i<length(x) do
  begin
    olda := a;
    oldb := b;
    oldc := c;
    oldd := d;

    a := ff(a, b, c, d, x[i+ 0], 7 , -680876936);
    d := ff(d, a, b, c, x[i+ 1], 12, -389564586);
    c := ff(c, d, a, b, x[i+ 2], 17,  606105819);
    b := ff(b, c, d, a, x[i+ 3], 22, -1044525330);
    a := ff(a, b, c, d, x[i+ 4], 7 , -176418897);
    d := ff(d, a, b, c, x[i+ 5], 12,  1200080426);
    c := ff(c, d, a, b, x[i+ 6], 17, -1473231341);
    b := ff(b, c, d, a, x[i+ 7], 22, -45705983);
    a := ff(a, b, c, d, x[i+ 8], 7 ,  1770035416);
    d := ff(d, a, b, c, x[i+ 9], 12, -1958414417);
    c := ff(c, d, a, b, x[i+10], 17, -42063);
    b := ff(b, c, d, a, x[i+11], 22, -1990404162);
    a := ff(a, b, c, d, x[i+12], 7 ,  1804603682);
    d := ff(d, a, b, c, x[i+13], 12, -40341101);
    c := ff(c, d, a, b, x[i+14], 17, -1502002290);
    b := ff(b, c, d, a, x[i+15], 22,  1236535329);

    a := gg(a, b, c, d, x[i+ 1], 5 , -165796510);
    d := gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
    c := gg(c, d, a, b, x[i+11], 14,  643717713);
    b := gg(b, c, d, a, x[i+ 0], 20, -373897302);
    a := gg(a, b, c, d, x[i+ 5], 5 , -701558691);
    d := gg(d, a, b, c, x[i+10], 9 ,  38016083);
    c := gg(c, d, a, b, x[i+15], 14, -660478335);
    b := gg(b, c, d, a, x[i+ 4], 20, -405537848);
    a := gg(a, b, c, d, x[i+ 9], 5 ,  568446438);
    d := gg(d, a, b, c, x[i+14], 9 , -1019803690);
    c := gg(c, d, a, b, x[i+ 3], 14, -187363961);
    b := gg(b, c, d, a, x[i+ 8], 20,  1163531501);
    a := gg(a, b, c, d, x[i+13], 5 , -1444681467);
    d := gg(d, a, b, c, x[i+ 2], 9 , -51403784);
    c := gg(c, d, a, b, x[i+ 7], 14,  1735328473);
    b := gg(b, c, d, a, x[i+12], 20, -1926607734);

    a := hh(a, b, c, d, x[i+ 5], 4 , -378558);
    d := hh(d, a, b, c, x[i+ 8], 11, -2022574463);
    c := hh(c, d, a, b, x[i+11], 16,  1839030562);
    b := hh(b, c, d, a, x[i+14], 23, -35309556);
    a := hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
    d := hh(d, a, b, c, x[i+ 4], 11,  1272893353);
    c := hh(c, d, a, b, x[i+ 7], 16, -155497632);
    b := hh(b, c, d, a, x[i+10], 23, -1094730640);
    a := hh(a, b, c, d, x[i+13], 4 ,  681279174);
    d := hh(d, a, b, c, x[i+ 0], 11, -358537222);
    c := hh(c, d, a, b, x[i+ 3], 16, -722521979);
    b := hh(b, c, d, a, x[i+ 6], 23,  76029189);
    a := hh(a, b, c, d, x[i+ 9], 4 , -640364487);
    d := hh(d, a, b, c, x[i+12], 11, -421815835);
    c := hh(c, d, a, b, x[i+15], 16,  530742520);
    b := hh(b, c, d, a, x[i+ 2], 23, -995338651);

    a := ii(a, b, c, d, x[i+ 0], 6 , -198630844);
    d := ii(d, a, b, c, x[i+ 7], 10,  1126891415);
    c := ii(c, d, a, b, x[i+14], 15, -1416354905);
    b := ii(b, c, d, a, x[i+ 5], 21, -57434055);
    a := ii(a, b, c, d, x[i+12], 6 ,  1700485571);
    d := ii(d, a, b, c, x[i+ 3], 10, -1894986606);
    c := ii(c, d, a, b, x[i+10], 15, -1051523);
    b := ii(b, c, d, a, x[i+ 1], 21, -2054922799);
    a := ii(a, b, c, d, x[i+ 8], 6 ,  1873313359);
    d := ii(d, a, b, c, x[i+15], 10, -30611744);
    c := ii(c, d, a, b, x[i+ 6], 15, -1560198380);
    b := ii(b, c, d, a, x[i+13], 21,  1309151649);
    a := ii(a, b, c, d, x[i+ 4], 6 , -145523070);
    d := ii(d, a, b, c, x[i+11], 10, -1120210379);
    c := ii(c, d, a, b, x[i+ 2], 15,  718787259);
    b := ii(b, c, d, a, x[i+ 9], 21, -343485551);

    a := add(a, olda);
    b := add(b, oldb);
    c := add(c, oldc);
    d := add(d, oldd);

    inc(i,16);
  end;
  Result:= rhex(a) + rhex(b) + rhex(c) + rhex(d);
end;

end.
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
ilk kod benden olsun vbde süzme
ara=text1.text
data1.recorsource="select*from tabloadi where alanadi like & "'ara'" &"
data1.refresh
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Private Sub Command1_Click()
For a = 0 To 9
For b = 0 To 9
For c = 0 To 9
For d = 0 To 9
For e = 0 To 9
For f = 0 To 9
sayi = Str(a) + Str(b) + Str(c) + Str(d) + Str(e) + Str(f)
List1.AddItem sayi
Next f
Next e
Next d
Next c
Next b
Next a
Label1.Caption = List1.ListCount
End Sub
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
SES KARTI VAR MI ?
'Module
Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Long
'Forma
Sub CheckSoundCard()
Dim i As Integer
i = waveOutGetNumDevs()
If i > 0 Then
MsgBox "Ses kartı bulundu !", vbInformation
Else
MsgBox "Ses kartı bulunamadı", vbInformation
End If
End Sub
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Delphi: Bilgisayarı kapat

Bilgisayarınızı ayarlanan saatte kapatmaya yarayan örnek bir kod [delphi]

Kod:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Buttons, ComCtrls,ShellApi, XPMan, Menus;

type
  TForm1 = class(TForm)
    kapat: TDateTimePicker;
    BitBtn1: TBitBtn;
    Timer1: TTimer;
    Label1: TLabel;
    BitBtn2: TBitBtn;
    XPManifest1: TXPManifest;
    PopupMenu1: TPopupMenu;
    ProgramGster1: TMenuItem;
    Kapat1: TMenuItem;
    Label2: TLabel;
    Timer2: TTimer;
    procedure Timer1Timer(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Kapat1Click(Sender: TObject);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure ProgramGster1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Timer2Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  stray:NOTIFYICONDATA;
implementation

{$R *.dfm}
function cikis(flag : word): Boolean;
var veri      : TOSVersionInfo;
    hToken  : THandle;
    tp      : TTokenPrivileges;
    h       : DWord;
begin
  result := false;
  veri.dwOSVersionInfoSize:=SizeOf(veri);
  GetVersionEx(veri);
  if veri.dwPlatformId = VER_PLATFORM_WIN32_NT then // Windows NT
  begin
      OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES,hToken);
    LookupPrivilegeValue(nil,'SeShutdownPrivilege',tp.Privileges[0].Luid);
    tp.PrivilegeCount := 1;
    tp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
    h := 0;
    AdjustTokenPrivileges(hToken,False,tp,0,PTokenPrivileges(nil)^,h);
    CloseHandle(hToken);
    result := ExitWindowsEx(flag,0);
    Application.Terminate;
  end
  else
    begin
    Result := ExitWindowsEx(flag,0);
    Application.Terminate;
  end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
VAR
KAL:STRING;
begin
bitbtn1.Visible:=false;
bitbtn2.Visible:=true;
if timetostr(kapat.Time)=timetostr(time) then begin
cikis(1);
end;
form1.Hint:=timetostr(kapat.Time-time)+' kaldı';
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
timer1.Interval:=1000;
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
begin
timer1.Interval:=0;
bitbtn1.Visible:=true;
bitbtn2.Visible:=false;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
kapat.Time:=time;
ZeroMemory(0, 0);
CreateMutex(nil,FALSE,'PROGRAMADI');
if GetLastError = ERROR_ALREADY_EXISTS then
begin
  ShowMessage('Program Zaten Çalışıyor. Program Kapatılacak!');
  Halt(0);
end;
//SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
  with stray do
  begin
    cbsize:=sizeof(stray);
    wnd:=form1.handle;
    hicon:=Application.icon.Handle;
    uID:=0;
    sztip:=' kaldı';
    uflags:=7;
    uCallBackMessage:=$200;//icon üzerine tıklama kontrolu için
  end;
     Shell_NotifyIcon(0,@stray);
end;

procedure TForm1.Kapat1Click(Sender: TObject);
begin
halt(0);
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var nokta:TPoint;
begin
  getCursorPos(nokta);
  if (x=$205) then PopupMenu1.Popup(nokta.x,nokta.y);
  if (x=$203) then BEGIN
  IF FORM1.ACTIVE=FALSE THEN BEGIN FORM1.Show; END
ELSE BEGIN FORM1.Hide; END;END;
  end;

procedure TForm1.ProgramGster1Click(Sender: TObject);
begin
IF FORM1.ACTIVE=FALSE THEN BEGIN FORM1.Show; END
ELSE BEGIN FORM1.Hide; END;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
action:=canone;
form1.Hide;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
label2.Caption:=timetostr(time);
end;

end.
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Delphi: Uluslararası Saatler

Masaüstünde diğer ülkelerin saatlerini sürekli görmek isteyenler için.
Uluslararası saat farklarını registry e kaydederek saatleri gösteren basit delhpi uygulaması.

Kod:
{Programın çalışması için registry e
istenilen ülke adlarını ve saat farklarını girmek gerekiyor.
bu kodları değiştirmek için ikinci bir form yapılarak ayarla butonuna bağlanabilir.
-----------------------------------------------------
[HKEY_LOCAL_MACHINESoftwareSaatUlke]
"1"="İstanbul"
"2"="Tokyo"
"3"="Paris"
"4"="Greenwich"
"5"="ABD"
"6"=""
"7"=""
"8"=""
"9"=""

[HKEY_LOCAL_MACHINESoftwareSaatFark]
"1"="+0000"
"2"="+0700"
"3"="-0100"
"4"="-0200"
"5"="-0800"
"6"=""
"7"=""
"8"=""
"9"=""
-----------------------------------------------------
Bir form üzerine bir StringGrid ve iki SpeedButton (Ayarla, Çıkış) yerleştirmek gerekiyor. FormStyle = ftStayOnTop seçilirse uygulama sürekli gözönünde olur..
kullanılan function ve procedure ler:

    Function  SaatHesapla(s:string):String;
    Procedure InitSaat;
    Procedure Basla;
    Function ReadUlke(avalue:string):string;
    Function ReadFark(avalue:string):string;
}

procedure TForm1.Timer1Timer(Sender: TObject);
var j: integer;
begin
  for j:=0 to sg1.RowCount do
   sg1.Cells[1,j] := SaatHesapla(sg1.Cells[2,j]);
end;

Function TForm1.SaatHesapla(s:string):String;
var
  saat,dak:longint;
  sign:string[1];
  Present: TDateTime;
  Hour, Min, Sec, MSec: Word;
  sSaat:string[5];
begin
  if s=" then exit;
  Sign:=Copy(s,1,1);
  if (sign<>'+') and (sign<>'-') then exit;
  try
    saat:=StrToInt(Copy(s,2,2));
    dak :=StrToInt(Copy(s,4,2));
  except
    exit;
  end;

  Present:= Now;
  DecodeTime(Present, Hour, Min, Sec, MSec);

  if sign='-' then begin
   saat:=-1*saat;
  end;

  Saat := Saat + Hour;
  Dak  := Dak + Min;

  if Dak > 59 then begin
    Saat:= saat + 1;
    Dak := Dak - 60;
  end;

  if Dak < 0 then begin
    Saat := saat - 1;
    Dak  := Dak + 60;
  end;

  if Saat > 23 then begin
    Saat := saat - 24
  end;

  if Saat < 0 then begin
    Saat := saat + 24
  end;

  sSaat := IntToStr(Saat)+':';
  if Saat< 10 then sSaat := '0' + sSaat;;
  if dak < 10 then sSaat := sSaat + '0';

  sSaat := sSaat + IntToStr(Dak);
  SaatHesapla:=sSaat;

end;


Function TForm1.ReadUlke(avalue:string):string;
var
  Reg : TRegistry;
begin
      Reg:=TRegistry.Create;
      Reg.RootKey:=HKEY_LOCAL_MACHINE;
      if Reg.OpenKey('SOFTWARESaatUlke',False) then Result :=Reg.ReadString(aValue);
      Reg.Free;
end;

Function TForm1.ReadFark(avalue:string):string;
var
  Reg : TRegistry;
begin
      Reg:=TRegistry.Create;
      Reg.RootKey:=HKEY_LOCAL_MACHINE;
      if Reg.OpenKey('SOFTWARESaatFark',False) then Result :=Reg.ReadString(aValue);
      Reg.Free;
end;

procedure Tform1.InitSaat;
var
  reg:TRegistry;
  Address:string;
  j:integer;
  function OpenCreateKey(s:string):boolean;
  begin
    Result := reg.OpenKey(s,true);
  end;
begin
  reg := TRegistry.Create;
  reg.RootKey := HKEY_LOCAL_MACHINE;

  address:='SOFTWARESaatUlke';
  if not reg.KeyExists(Address) then begin
    if OpenCreateKey(Address) then begin
      for j:=1 to Form2.sg2.RowCount-1 do
          reg.WriteString(IntToStr(j),Trim(Form2.sg2.Cells[0,j]));
      reg.CloseKey;
    end;
  end else begin
    if OpenCreateKey(Address) then begin
          for j:=1 to Form2.sg2.RowCount-1 do
           if not reg.ValueExists(IntToStr(j))  then
             reg.WriteString(IntToStr(j),Trim(Form2.sg2.Cells[0,j]))
           else
             reg.WriteString(IntToStr(j),Trim(Form2.sg2.Cells[0,j]));
      reg.CloseKey;
    end;
  end;

  address:='SOFTWARESaatFark';
  if not reg.KeyExists(Address) then begin
    if OpenCreateKey(Address) then begin
      for j:=1 to Form2.sg2.RowCount-1 do
          reg.WriteString(IntToStr(j),Trim(Form2.sg2.Cells[1,j]));
      reg.CloseKey;
    end;
  end else begin
    if OpenCreateKey(Address) then begin
          for j:=1 to Form2.sg2.RowCount-1 do
           if not reg.ValueExists(IntToStr(j))  then
             reg.WriteString(IntToStr(j),Trim(Form2.sg2.Cells[1,j]))
           else
             reg.WriteString(IntToStr(j),Trim(Form2.sg2.Cells[1,j]));
      reg.CloseKey;
    end;
  end;
  reg.Free;
end;

Procedure TForm1.Basla;
var j:integer;
begin
   sg1.RowCount:=9;
   j:=0;
   While j<sg1.RowCount do begin
      Sg1.Cells[0,j] := ReadUlke(IntToStr(j+1));
      Sg1.Cells[2,j] := Readfark(IntToStr(j+1));
      sg1.Cells[1,j] := SaatHesapla(sg1.Cells[2,j]);

      if Sg1.Cells[0,j] = " then sg1.RowCount:=j;
      inc(j);

   end;

   Form1.left := screen.width - Form1.width;
   Form1.Height := sg1.RowCount * sg1.DefaultRowHeight + 40;
   Form1.top := screen.Height - Form1.Height - 30;

end;

procedure TForm1.FormShow(Sender: TObject);
begin
   Basla;
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
  Application.terminate;
end;

procedure TForm1.SpeedButton2Click(Sender: TObject);
var
  J : Integer;
begin
  with Form2.sg2 do begin
     for J:= 1 to RowCount - 1 do begin
        Cells[0,J] := ReadUlke(IntToStr(j));
        Cells[1,J] := ReadFark(IntToStr(j));
     end;
  end;
  if Form2.ShowModal=mrOk then InitSaat;
  Basla;
end;
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Delphi: Not Defteri

Kod:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    Memo1: TMemo;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    Button1: TButton;
    ColorDialog1: TColorDialog;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure ComboBox2Change(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);
begin

memo1.Font.Style:=memo1.Font.Style+[fsBold];
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
begin
memo1.Font.Style:=memo1.Font.Style+[fsItalic];
end;

procedure TForm1.BitBtn3Click(Sender: TObject);
begin
memo1.Font.Style:=memo1.Font.Style+[fsUnderline];
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
memo1.Alignment:=taLeftJustify;
end;

procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
memo1.Alignment:=tacenter;

end;

procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
memo1.Alignment:=taRightJustify;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
combobox1.Items.Add('Arial');
combobox1.Items.Add('Times New Roman');
combobox1.Items.Add('Comic Sans');
combobox2.Items.Add('8');
combobox2.Items.Add('16');
combobox2.Items.Add('32');
end;

procedure TForm1.ComboBox1Change(Sender: TObject);
begin

if ComboBox1.Text='Times New Roman' then begin
memo1.Font.Name:='Times New Roman';
end
else if ComboBox1.Text='Comic Sans' then begin
memo1.Font.Name:='Comic Sans';
end
else if ComboBox1.Text='Arial' then begin
memo1.Font.Name:='Arial';
end
else begin
end;
end;

procedure TForm1.ComboBox2Change(Sender: TObject);
begin
if ComboBox2.Text='8' then begin
memo1.Font.Size:=8;
end
else if ComboBox2.Text='16' then begin
memo1.Font.Size:=16;
end
else if ComboBox2.Text='32' then begin
memo1.Font.Size:=32;
end
else begin
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
ColorDialog1.Execute;
if ColorDialog1.Execute=true then begin
Memo1.Font.Color:=ColorDialog1.Color;
end;
end;

end.
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Bu da basit bir javascript kodu:Verilen sayının yüzedesini hesaplıyor

<html>
<head>
<title>Yüzde Hesaplayan Web Sayfası</title>
</head>
<body>
<form name="theform">
<br>
<b>Sayıların Yüzdesini Hesaplayan Javascript Örneği</b>
<br><br>
<input name="sayi" value=0 maxlenght=4 size=3> sayısının yüzde
<input name="yuzde" value=0 maxlength=3 size=2> kadarı kaçtır ?
<script language="javascript">
function basla()
{
var ilkdeger =
document.theform.sayi.value

var sondeger =
document.theform.yuzde.value

var yuzdesi = (ilkdeger / 100) * sondeger

document.theform.sonuc.value = yuzdesi
}
</script>
<br>
<input type="button" name="hesapbutonu" value="Hesapla !" onclick="basla()">

<input name="sonuc" value="Sonuç" readonly="1">
</form>
</body>
</html>
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Son birkac günde asal sayilarla ilgili program isteyen arkadaslar oldu. Ben de önceden yazmis oldugum C kodunu düzenledim. Buyrun.
Asal carpanlara ayirma:

Kod:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>

bool isPrime(unsigned long long num){
    bool status = true;
    unsigned long long ref = 3;
    
    if((num % 2 == 0 && num != 2) || num < 2)
        status = false;
    else
        while(ref * ref <= num){
            if(num % ref == 0){
                status = false;
                break;
            }
            else
                ref = ref + 2;
        }
        
    return status;        
}
                  

int main(int argc, char *argv[])
{
  unsigned long long num = 0;
  
  printf("Primefactors...\n");
  printf("maxVal = %I64u\n\n", ULLONG_MAX);
  
  do{
  printf(">> ");
  
  while(scanf("%I64u", &num) == 0){
       while(getchar() != '\n');  
       printf("input error!\n\n>> ");
  }
  
  if(isPrime(num) == true){
     printf("\n");
     printf("%I64u is prime\n", num);
  } 
  else if(num > 1){
     unsigned long long factor = 3;
                   bool asterixReq = false;
                   long pow = 0;

    printf("\n%I64u =", num);     
    
    while(num % 2 == 0){
        num = num / 2;
        pow = pow + 1;
    }
        
    if(pow == 1){
        printf(" (2)");
        asterixReq = true;
    }
    else if(pow > 1){
        printf(" (2^%ld)", pow);
        asterixReq = true;
    }
    
    while(factor * factor <= num){
        pow = 0;
                          
     if(num % factor == 0 && isPrime(factor) == true){ //the order of the statements     
             while((num % factor) == 0){                     //makes a big speed difference
                num = num / factor;
                pow = pow + 1;
            }    
       }        
       
         if(pow >= 1){
         
            if(pow == 1){            
             printf(" %c (%I64u)", asterixReq == true ? '*' : ' ', factor);     
              asterixReq = true;
            }
            else{
             printf(" %c (%I64u^%ld)", asterixReq == true ? '*' : ' ', factor, pow);
              asterixReq = true;
            }
         }                 
      
        factor = factor + 2;    
   }
    if(num != 1 && factor * factor > num)
            printf(" * (%I64u)", num);            
       } 
   printf("\n\n\n");
   }
while(1);                                 
}

Bu program microsoft'un I64 degisken tipini kullaniyor. ANSI uyumlu bir derleyicide derlemek icin "I64" yazan yerleri "ll" ile degistirmek yeterli olacaktir.


Bu da biraz daha optimize edilmis hali. Daha hizli olmasi gerek ama birkac bug da olabilir; test etmedim tam anlamiyla!!

Kod:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>



bool isPrime(unsigned long long num){
    bool status = true;
    unsigned long long ref = 3;
    
    if((num % 2 == 0 && num != 2) || num < 2)
        status = false;
    else
        while(ref * ref <= num){
            if(num % ref == 0){
                status = false;
                break;
            }
            else
                ref = ref + 2;
        }
    return status;        
}


unsigned long long isPrimeStartVal(unsigned long long num, unsigned long long ref){
        while(1){
            if(ref * ref > num){
                ref = 0;
                break;
            }
            else if(num % ref == 0)
                break;
            else
                ref = ref + 2;
        }     
    return ref;        
}
                  

int main(int argc, char *argv[])
{
  unsigned long long num = 0;
  
  printf("Primefactors...\n");
  printf("maxVal = %I64u\n\n", ULLONG_MAX);
  
  while(1){
  printf(">> ");
  
  while(scanf("%I64u", &num) == 0){
       while(getchar() != '\n');  
       printf("input error!\n\n>> ");
  }
  
  if(isPrime(num) == true){
     printf("\n");
     printf("%I64u is prime\n\n", num);
  } 
  else if(num > 1){
     unsigned long long factor = 3;
                   long pow = 0;

    printf("\n%I64u =", num);     
    
    while(num % 2 == 0){
        num = num / 2;
        pow = pow + 1;
    }
        
    if(pow == 1){
        printf(" (2)");
    }
    else if(pow > 1){
        printf(" (2^%ld)", pow);
    }
    
    while(factor <= num){
        pow = 0;
                            
       if(num % factor == 0)       
              do{
                num = num / factor;
                pow = pow + 1;
            }
            while((num % factor) == 0);    
               
       
         if(pow >= 1){
         
            if(pow == 1){            
              printf(" (%I64u)", factor);      
            }
            else{
              printf(" (%I64u^%ld)", factor, pow);
            }
         } 
                           
        if((factor = isPrimeStartVal(num, factor)) == 0){
            if(num != 1)
                printf(" (%I64u)", num); 
            break;
        }
          
   }
   printf("\n\n\n");
   }
                                     
}


}
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Basit bir arkanoid Oyunu (yenilerin anlaması dxball diyelim.)

pencere.h

Kod:
pencere(int x1,int y1,int x2,int y2,int tip,int renk) { int i; char solust,sagust,sagalt,solalt,dikey,yatay; textcolor(renk); if (tip==1) { solust=201; sagust=187; solalt=200; sagalt=188; dikey=186; yatay=205; } if (tip==2) { solust=218; sagust=191; solalt=192; sagalt=217; dikey=179; yatay=196; } gotoxy(x1,y1); cprintf("%c",solust); for (i=x1;i<x2;i++) cprintf("%c",yatay); gotoxy(x2,y1);cprintf("%c",sagust); for (i=y1+1;i<y2;i++) { gotoxy(x1,i);cprintf("%c",dikey); gotoxy(x2,i);cprintf("%c",dikey); } gotoxy(x1,y2); cprintf("%c",solalt); for (i=x1;i<x2;i++) cprintf("%c",yatay); gotoxy(x2,y2); cprintf("%c",sagalt); return 0; }
Arkanoid.c
Kod:
#include <stdio.h> #include <dos.h> #include <pencere.h> main() {struct time t; char tus; int cubukx=19,topx=15,topy=15; int xa=1,ya=1,i,j,k; int kutu_x[4]={12,27,44,60}; int kutu_y[4]={7,7,7,7}; /*bu degikenler kutularn koordinatlarini tutacak kutularin genisligini bildigimiz icin x1,x2 seklinde tanimlamadik sadece x,y koordinatlari yeterli */ int kutu[4]={1,1,1,1}; /*bu dizide i. kutunun daha onceden kirilip kirilmadigina bakacagiz deger 0 sa kirilmis*/ const char cubuk[11]="----------"; clrscr(); textcolor(10); pencere(10,1,70,3,1,2); pencere(10,4,70,22,2,15); pencere(10,23,70,24,2,2); /*kutularimizi yerlestirelim*/ for (i=0;i<=3;i++) pencere(kutu_x,kutu_y,kutu_x+6,kutu_y+1,2,2); /*4 tane yeter*/ textcolor(15);gotoxy(cubukx,21); cprintf("%s",cubuk); do{ do{ gettime(&t); gotoxy(12,2);cprintf("saat: %2d:%02d:%02d",t.ti_hour, t.ti_min, t.ti_sec); /* topumuzun hareket bolumu */ topx=topx+xa; topy=topy+ya; if (topy==22) { pencere(30,10,50,14,1,5); gotoxy(32,12);printf("GAME OVER"); getch(); return; } if (topx==12) xa=1; if (topx==68) xa=-1; if (topy==5) ya=1; if (topy>19 && topx>=cubukx && (topx<=cubukx+10)) ya=-1; /*kutulardan birine carpinca geri don kutuyu kaldir*/ for (i=0;i<=4;i++) { k=k+1; if ((kutu==1) && (topx>=kutu_x) && (topx<kutu_x+6) && (topy>=kutu_y) && (topy<=kutu_y+3)) { kutu=0; ya=-ya; pencere(kutu_x,kutu_y,kutu_x+6,kutu_y+1,2,0); } } /*-------------*/ textcolor(10);gotoxy(topx,topy);cprintf("*");delay(50); gotoxy(topx,topy);cprintf(" "); /* ----------------------------*/ }while(!kbhit()); /*aksiyon bolumu*/ tus=getch(); if (tus==0) { tus=getch(); gotoxy(cubukx,21); cprintf(" "); switch(tus) { case 'K': {cubukx==11 ?(cubukx=cubukx):(cubukx=cubukx-2);break;} case 'M': {cubukx==59 ?(cubukx=cubukx):(cubukx=cubukx+2);break; } }/*switch*/ textcolor(15);gotoxy(cubukx,21); cprintf("%s",cubuk); } }while(tus!=27); }
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Basit bir takvim c# öğrenmek isteyenler için iyi bir örnek.


using System;

namespace Takvim_2
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Console.WriteLine("Lutfen yılı girin");
int yil=int.Parse(Console.ReadLine());
Console.WriteLine("Lutfen yılın ilk gununu girin..(pazartesi için 1 salı için 2 vs....)");
int gun=int.Parse(Console.ReadLine());
int[] gunler={31,28,31,30,31,30,31,31,30,31,30,31};
string[] ay={"Ocak","Subat","Mart","Nisan","Mayıs","Haziran ","Temmuz","Agustos","Eylul","Ekim","Kasım","Aralı k"};
int[,,] takvim=new int[12,6,7];
if((yil%4)==0)
{
gunler[1]=29;
}
int i=0;
int k=0;
int x=0;
int a=0;
string s="0";
Console.WriteLine();
while(a<12)
{
for(i=0; i<6; ++i)
{
for(k=0; k<7; ++k)
{
x=x+1;
takvim[a,i,k+gun-1]=x;

if((k+gun-1)==6)
{break;}
if(x==gunler[a])
{break;}
}

gun=1;
if(x==gunler[a])
{break;}

}
if(k==0)
{gun=2;}
if(k==1)
{gun=3;}
if(k==2)
{gun=4;}
if(k==3)
{gun=5;}
if(k==4)
{gun=6;}
if(k==5)
{gun=7;}
if(k==6)
{gun=1;}
i=0;
k=0;
x=0;
a=a+1;
}
int c=0;
while(c<12)
{
Console.WriteLine(" {0} ",ay[c]);
Console.WriteLine("--------------------");
Console.WriteLine("Pa Sa Ça Pe Cu Cum Pa");
Console.WriteLine("--------------------");
for(int y=0; y<6; ++y)
{
for(int t=0; t<7; ++t)
{
if(takvim[c,y,t]==0)
{
Console.Write(" ");
goto dip;
}
if(takvim[c,y,t]==1 || takvim[c,y,t]==2 || takvim[c,y,t]==3 || takvim[c,y,t]==4 || takvim[c,y,t]==5
|| takvim[c,y,t]==6 || takvim[c,y,t]==7 || takvim[c,y,t]==8 || takvim[c,y,t]==9)
{
s=s+Convert.ToString(takvim[c,y,t])+" ";
Console.Write(s);
goto dip2;
}
Console.Write(Convert.ToString(takvim[c,y,t])+" ");
dip:
dip2:
s="0";
}
Console.WriteLine();
}
c=c+1;
}
Console.ReadLine();
}
}
}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Alın size güzel bir oyun
smile.gif


using System;
using System.Collections;
namespace SnowBallFighter
{
/// <summary>
/// Basic Snowball fighter
/// </summary>
public class Fighter
{
//instance variables
private int pStrength;
private int pSnowballs;
private string pName;

//properties
public int strength
{
get
{
return pStrength;
} // end get
set
{
pStrength = value;
} // end set
} // end strength

public int snowballs
{
get
{
return pSnowballs;
} // end get
set
{
pSnowballs = value;
} // end set
} // end snowballs
public string name
{
get
{
return pName;
} // end get
set
{
pName = value;
} // end set
} // end name

public Fighter(string theName)
{
//initialize
snowballs = 3;
strength = 3;
name = theName;
} // end constructor

public bool throwSnow(int range)
{
//calculates likeliness of a hit at a given range
//returns true if snowball hit
bool hit = false;
int myRoll;
Random roller = new Random();
if (snowballs <= 0)
{
Console.WriteLine ("{0} is out of snowballs!", name);
}
else
{
myRoll = roller.Next(10);
if (myRoll > range)
{
hit = true;
} // end hit if
snowballs--;
} // end out of snowballs if
return hit;
} // end throwSnow method
}
/// <summary>
/// RoboFighter
/// A computer-controlled snowball fighter
/// derived from fighter
/// </summary>
public class RoboFighter: Fighter
{
private Fighter player;
public RoboFighter(Fighter thePlayer, string theName): base(theName)
{
player = thePlayer;
} // end constructor

public int choosePlay(int range)
{
int thePlay;
Random roller = new Random();
if (snowballs <= 0)
{
//make a new snowball if out of them
Console.WriteLine(name + " is making a snowball");
snowballs++;
}
else
{
//decide to throw or move
thePlay = roller.Next(6);
switch (thePlay)
{
case 0:
//go closer
Console.WriteLine("{0} moves closer.", name);
range--;
break;
case 1:
//back up
Console.WriteLine("{0} backs away.", name);
range++;
break;
case 2:
//make a snowball
Console.WriteLine(name + " is making a snowball");
snowballs++;
break;
default:
//otherwise, throw a snowball
Console.WriteLine("{0} throws a snowball", name);
if (throwSnow(range))
{
Console.WriteLine("{0} has been hit", player.name);
player.strength--;
}
else
{
Console.WriteLine("{0} missed you.", name);
} // end if
break;
} // end switch
} // end out of snowballs if
return range;
} // end choosePlay
}
/// <summary>
/// A snowball fight against a robot opponent
/// demonstrates object-oriented programming
/// Andy Harris, 12/23/01
///</summary>
class MainMenu
{
int range; //distance between fighters
Fighter player; //human player
RoboFighter opponent; //robot opponent
bool keepGoing = true; //controls main loop
static void Main(string[] args)
{
MainMenu mm = new MainMenu();
}
public MainMenu()
{
int choice;
string name;
//set up the contestants
Console.Write("What is your name? ");
name = Console.ReadLine();
player = new Fighter(name);
Console.Write("What's your opponent's name? ");
name = Console.ReadLine();
opponent = new RoboFighter(player, name);
range = 10;
while(keepGoing)
{
choice = displayMenu();
switch (choice)
{
case 0:
//quit
Console.WriteLine("quitting");
keepGoing = false;
break;
case 1:
//make a snowball
player.snowballs++;
break;
case 2:
range--;
if (range < 0)
{
range = 0;
} // end if
break;
case 3:
range++;
break;
case 4:
if (player.throwSnow(range))
{
Console.WriteLine("You hit {0}", opponent.name);
opponent.strength--;
}
else
{
Console.WriteLine("You missed {0}", opponent.name);
} // end if
break;
default:
Console.WriteLine("you said {0}", choice);
break;
} // end switch
range = opponent.choosePlay(range);
checkWinner();
} // end while loop
} // end constructor
public void checkWinner()
{
if (opponent.strength <= 0)
{
Console.WriteLine("You win!");
keepGoing = false;
Console.ReadLine();
}
else if (player.strength <= 0)
{
Console.WriteLine("You have been defeated");
keepGoing = false;
Console.ReadLine();
} // end if
} // end checkWinner

public int displayMenu()
{
int choice;
Console.WriteLine("Stats:");
Console.WriteLine(" distance: \t{0}", range);
Console.WriteLine(" snowballs: \t{0}", player.snowballs);
Console.WriteLine(" {0}: \t{1}", player.name, player.strength);
Console.WriteLine(" {0}: \t{1}", opponent.name, opponent.strength);
Console.WriteLine();
Console.WriteLine("0. Quit");
Console.WriteLine("1. Make a snowball");
Console.WriteLine("2. Move closer");
Console.WriteLine("3. Run away");
Console.WriteLine("4. Throw");
Console.WriteLine();
Console.Write("Indicate your choice: ");
choice = Convert.ToInt32(Console.ReadLine());
Console.WriteLine();
Console.WriteLine();
return choice;
} // end dispayMenu
}
}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Selamlar arkadaslar..Sizinle lab icin hazirladigim C kodlariyla olusturulmus array_matrix calismasini paylasiyorum......





#include<stdio.h>

void scalar_mul(int matrix[3][2],int k);

void add(int matrix1[3][2],int matrix2[3][2]);

void transpose(int matrix5[2][3],int matrix6[3][2]);

int main()
{
int matrix1 [2][3]= {{1,0,0},{0,0,1} };
//int i,j;
int matrix2[3][2]={{-1,3},{6,-6},{-3,-1}};
int matrix3[3][2]={{1,-2},{-4,4},{2,1}};
int matrix4[3][2];
for(int i=0;i<2;i++)
{ printf("\n");
for(int j=0;j<3;j++)
{printf("%d\t",matrix1 [j]);}

}
printf("\n-----------------------------------------------\n");
scalar_mul(matrix2,2);

scalar_mul(matrix3,3);

add(matrix2,matrix3);

transpose(matrix1,matrix4);



for(int m=0;m<3;m++)
{ printf("\n");
for(int n=0;n<2;n++)
{
printf("%d\t",matrix4[m][n]);
}


}


printf("\n-----------------------------------------------\n");



for(int y=0;y<3;y++)
{ printf("\n");
for(int z=0;z<2;z++)
{
printf("%d\t",matrix2[y][z]);
}


}



return(0);
}


void scalar_mul(int matrix[3][2],int k)
{ for(int g=0;g<3;g++)
{
for(int l=0;l<2;l++)

{
matrix[g][l]= k*matrix[g][l] ;
}
}


}


void add(int matrix1[3][2],int matrix2[3][2])
{ for(int k=0;k<3;k++)
{
for(int l=0;l<2;l++)

{
matrix1[k][l]+=matrix2[k][l] ;
}
}


}


void transpose(int matrix5[2][3],int matrix6[3][2])
{
for(int k=0;k<3;k++)
{
for(int l=0;l<2;l++)

{
matrix6[k][l]=matrix5[l][k];
}
}






}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
c++ da belirlenen aralikta rasgele bir sayi ureten ve bu sayiyi tahmin etmenizi isteyen,bu sirada sizi yonlendiren bir program..
----------------------------------------------------------------
//tahmin.cpp
//1 ile istenilen sayi arasinda bir rasgele sayi uretir
//ve kullanicidan bu sayiyi tahmin etmesini ister
//bu sirada tutulan sayiya dogru kullaniciyi yonlendirir
//---------------------------------------------------------------------------
#include <iostream.h>
#include <conio.h>
#include <time.h>
#include <stdlib.h>
//---------------------------------------------------------------------------
int main()
{
int aralik, //tahmin oyununun limiti
sayi, //programin tutacagi sayi
giris, //kullanicinin tahmini
gsayi=0, //yapilan giris sayisi
girilenler[100]; //girilen sayilari tutar
do
{ //limiti al
cout<<endl<<"Lutfen limit olarak kullanilacak sayiyi girin :";
cin>>aralik;
cin.clear();
cin.ignore(150,'\n');
if ((aralik>10000)||(aralik<50)) //program 50-10000 arasina sinirlandirildi
cout<<"Hatali giris!\n"<<endl
<<"Lutfen 50-10000 araliginda bir sayi giriniz!";
}
while((aralik<50)||(aralik>10000));
cout<<endl<<endl<<"Aralik 1-"<<aralik<<" olarak belirlendi..."<<endl
<<endl<<"Devam etmek icin bir tusa basin...";
getch();
clrscr();
srand(time(NULL));
sayi=((rand()%aralik)+1); //rasgele bir sayi tut
cout<<"Su anda [1-"<<aralik<<"]araliginda bir sayi tuttum !"
<<endl<<"Senden bunu tahmin etmeni istiyorum..."
<<endl<<"Bu sirada sana 'daha buyuk' ve 'daha kucuk' diyerek yardimci olacam..."
<<endl<<endl<<"Hazirsan baslamak icin bir tusa bas...";
getch();
clrscr();
do
{
do //kullanicidan tahmin al
{
cout<<"Aralik : [1-"<<aralik<<"]"<<endl
<<endl<<"Lutfen bir sayi gir :";
cin>>giris;
clrscr();
if ((giris>aralik)||(giris<1)) //tahmin dogru araliktami?
cout<<"Hatali giris!\n"<<endl
<<"Lutfen 1-"<<aralik<<" araliginda bir sayi giriniz!";
cin.clear();
cin.ignore(150,'\n');
}
while((giris<1)||(giris>aralik));
girilenler[gsayi++]=giris;
if(giris==sayi) //tahmini kontrol et
{
clrscr();
cout<<endl<<endl<<endl<<endl
<<"Tebrikler "
<<"Tuttugum sayi "<<sayi<<" idi"<<endl<<endl<<endl
<<gsayi<<" defada bildin.."<<endl<<endl
<<"Simdiye kadar girdiginiz sayilar :"<<endl;
for(int i=0;i<gsayi;i++)
cout<<girilenler<<" ";
cout<<endl;
break;
}
else if(giris>sayi)
cout<<" Daha kucuk.."<<endl<<endl;
else if(giris<sayi)
cout<<" Daha buyuk.."<<endl<<endl;
cout<<"Simdiye kadar girdiginiz sayilar :"<<endl;
for(int i=0;i<gsayi;i++)
cout<<girilenler<<" ";
cout<<endl;
giris=0;
}
while (1); //cikis
cout<<endl<<endl<<endl<<"Devam etmek icin bir tusa basiniz...";
getch();
clrscr();
cout<<endl<<endl<<"\"NESHE CORPORATION\"\n\n\nTarafindan hazirlanmis yazilimlar kullandiginiz icin tesekkurler..\n\n"<<endl
<<"Cikmak icin herhangi bir tusa basiniz............";
getch();
return 0;
}
//---------------------------------------------------------------------------
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
c++ ile verilen sayiya kadar olan asallari hesaplayip ekrana yazan program..
sayilarin hesaplanma suresini de gosteriyor..
__________________________________________________ ________________
//---------------------------------------------------------------------------
#include <iostream.h>
#include <conio.h>
#include <math.h>
#include <iomanip.h>
#include <time.h>
#include <stdlib.h>
//---------------------------------------------------------------------------
char bos20[]=" ";
int gsayi;
long int zaman1,zaman2;
bool onay;
void hesaplama(void);
//---------------------------------------------------------------------------
void Hakkinda(void)
{
clrscr();
cout<<"########################################### ######################"<<endl<<endl;;

cout<<"Name:::::::::: Asal Sayilar"<<endl;
cout<<"Version::::::: 0.5.1"<<endl;
cout<<"Programmer:::: "<<endl;
cout<<"Company::::::: Neshe Corp."<<endl;
cout<<"eMail::::::::: "<<endl;
cout<<"Tİme:::::::::: 04/07/2005 Monday 16:03"<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<"Sonraki sayfaya gecmek icin bir tusa basiniz..."<<endl;
getch();
clrscr();

cout<<"########################################### ######################"<<endl<<endl;

cout<<"Bu program 1'den belirtilen sayiya kadar olan asal sayilari bularak"<<endl;
cout<<"ekranda gostermektedir.Bu islem icin klasik bolme yontemini"<<endl;
cout<<"kullanmaktadir."<<endl;
cout<<"Girilen sayinin buyuklugu arttikca programin sonuca ulasma suresi"<<endl;
cout<<"uzamaktadir."<<endl<<endl<<endl<<endl<<endl <<endl<<endl;
cout<<"Sonraki sayfaya gecmek icin bir tusa basiniz..."<<endl;
getch();
clrscr();

cout<<"########################################### ######################"<<endl<<endl;

cout<<"Bu program istenildigi sekilde dagitilabilir."<<endl<<endl<<endl<<endl<<endl<<end l<<endl;
cout<<"Sonraki sayfaya gecmek icin bir tusa basiniz..."<<endl;
getch();
clrscr();

cout<<"########################################### ######################"<<endl<<endl;

cout<<"Bu programin kullanimi veya kopyalanmasi sonucu olusabilecek herhangi"<<endl;
cout<<"bir hasar veya kayiptan dolayi programci veya firma sorumlu degildir."<<endl<<endl
<<endl<<endl<<endl<<endl<<endl;
cout<<"Sonraki sayfaya gecmek icin bir tusa basiniz..."<<endl;
getch();
clrscr();

cout<<"########################################### ######################"<<endl<<endl;

cout<<"Herhangi bir hata,istek ve onerileriniz icin yukardaki mail adresine"<<endl;
cout<<"7/24 mail gonderebilirsiniz."<<endl;
cout<<"Mailleriniz en kisa zamanda degerlendirmeye alinacak ve gerekirse"<<endl;
cout<<"programda degisiklige gidilecektir."<<endl<<endl<<endl<<endl<<endl<<endl <<endl;
cout<<"Sonraki sayfaya gecmek icin bir tusa basiniz..."<<endl;
getch();
clrscr();

cout<<"########################################### ######################"<<endl<<endl;

cout<<"YENILIKLER"<<endl;
cout<<"----------"<<endl;
cout<<"Bu versiyonda program hesaplama suresini CPU'daki Saate gore hesaplayip"<<endl;
cout<<"islem bitiminde kullaniciya gostermektedir."<<endl;
cout<<"Bu sayede bir nevi islemcinizin belli bir asali ne kadar zamanda"<<endl;
cout<<"digini ogrenip, diger CPU'larla kiyaslama yapabilirsiniz."<<endl<<endl;

cout<<"Sizde sisteminizde bu hasabin ne kadar surdugunu belirten bir maili"<<endl;
cout<<"bana gonderirseniz,bundan sonraki versiyonlarda kullanicilar kendi"<<endl;
cout<<"sistemlerini bircok sistemle sayisal hesap yapma acisindan kiyaslayarak"<<endl;
cout<<"bir nevi bilgisayarlarinin ne kadar iyi oldugunu bilebilirler.."<<endl
<<endl<<endl<<endl<<endl<<endl;
cout<<"Sonraki sayfaya gecmek icin bir tusa basiniz..."<<endl;
getch();
clrscr();
cout<<"-----------------------------------------------------------------------"<<endl;
cout<<"Bu son versiyonda aslinda koklu sayilabilecek degisiklikler yapilmistir."<<endl;
cout<<"Bunlar sayinin asalligini kontrol eden fonksiyonun calismasini belirgin"<<endl;
cout<<"bir sekilde hizlandirmistir.Bunu bir onceki trestimizle kiyaslamak"<<endl;
cout<<"gerekirse:"<<endl;
cout<<"100000'e kadar olan asallarin bulunmasi islemi 6.199sn surmektedir."<<endl;
cout<<"Burdan basit bir hesapla programin yaklasik 24 kat hizlandirildigi"<<endl;
cout<<"sonucuna varilmaktadir(Eski versiyonda ayni islem 150.006sn surmekte idi)"<<endl;
cout<<"Bu hiz artis orani tabiki gercegi yansitmamaktadir.Cunku her farkli"<<endl;
cout<<"hesaplama araligi icin yapilan islemler azaldigi icin bir onceki"<<endl;
cout<<"versiyonla kiyaslama yapmak mantiksizdir."<<endl;
cout<<"Ama kullaniciya bir fikir vermesi acisindan onemlidir."<<endl<<endl<<endl<<endl<<endl<<endl<<e ndl;
cout<<"Devam etmek icin bir tusa basiniz..."<<endl;
getch();
clrscr();
}
//---------------------------------------------------------------------------
void cikis(void)
{
clrscr();
cout<<endl<<endl<<"\"NESHE CORPORATION\"\n\n\nTarafindan hazirlanmis yazilimlar kullandiginiz icin tesekkurler..\n\n"<<endl;
cout<<"Cikmak icin herhangi bir tusa basiniz............";
getch();
exit(0);
}
//---------------------------------------------------------------------------
void giris(void)
{

cout<<endl<<endl<<endl;
cout<<bos20<<" "<<"ASAL SAYILAR"<<" v0.5.1.2"<<endl;
cout<<bos20<<"----------------------------------------"<<endl<<endl;
cout<<bos20<<"Bu program girdiginiz sayiya kadar olan "<<endl;
cout<<bos20<<"asal sayilari bularak ekranda gosterir. "<<endl;
cout<<bos20<<"Eger istediginiz asala ulasirsaniz prog-"<<endl;
cout<<bos20<<"ramin durmasi icin herhangi bir tusa ba-"<<endl;
cout<<bos20<<"siniz,unutmayin devam edemeyeceksiniz.. "<<endl;
cout<<bos20<<"Programdan cikmak icin -1 giriniz"<<endl<<endl;
cout<<bos20<<"Bulmasi istenen sayi miktari arttikca "<<endl;
cout<<bos20<<"buna bagli olarak surede uzayacaktir...."<<endl<<endl<<endl;
cout<<"Devam etmek icin bir tusa basiniz...";
getch();
}
//---------------------------------------------------------------------------
void kontrol(void)
{
int secenek;
int a=1;
do
{
clrscr();
cout<<endl<<endl<<endl
<<bos20<<"Secenekler:"<<endl;
cout<<bos20<<"-----------"<<endl;
cout<<bos20<<"1.Sayi Gir"<<endl;
cout<<bos20<<"2.Hakkinda&Readme"<<endl;
cout<<bos20<<"3.Cikis"<<endl<<endl<<endl;
cout<<"Lutfen istediginiz secenegin numarasini giriniz :";
cin>>secenek;
cin.clear();
cin.ignore(150,'\n');
switch(secenek)
{
case 1 : hesaplama();break;
case 2 : Hakkinda();break;
case 3 : cikis();
default :continue;
}
secenek=5;
}
while(a==1);
}
//---------------------------------------------------------------------------
void hesaplama(void)
{
clrscr();
cout<<"Lutfen bir sayi giriniz :";
cin>>gsayi;
cin.clear();
cin.ignore(150,'\n');
clrscr();
if (gsayi>=2) //2'den kucuk asal olmadigi icin kontrol burdan basliyor
{
cout<<gsayi<<" sayisina kadar bulunan asallar :"<<endl;
zaman1=clock(); //hesaplama burdan basliyor ve zamanda calistiriliyor
cout<<setw(8)<<2<<setw(8);
int cikti = 1; //kac adet asal sayi bulundugunu tutan degisken
for (int i=3 ; i<=gsayi ; i +=2) //2 zaten asal oldugundan kontrol 3'ten baslar ve tek sayilar icin surer
{
onay=true; //sayi asalsa onaylanir
for (int j=3 ; j<=((i/2)-1) ; j+=2) //her sayi kendisinin yarisina kadar olan sayilara bolunerek kontrol
{ //ediliyor.Sayilar ucten basladigindan ciftlere bolmeye gerek yok.
if ((i%j) == 0) //tam bolunme varsa asallik yok
{
onay =false;
break; //sayi bir sayiya tam bolunurse artik asal degildir ve
} //bolme biter
}
if (onay==true)
{
cout<<i<<setw(8); //sayi tum islemlerden asal ciktiysa ekrana yazdirilir
cikti +=1; //ve asal olarak bulunan sayi miktari arttirilir
}
if (kbhit()) //islem kullanici tarafindan bir tusa basilarak durdurulabilir
{
cout<<endl<<"Program kullanici tarafindan durduruldu !!!";
zaman2 = clock(); //kullanici islemi durdurdugu icin zaman burda bitmis demektir
break;
}
}
zaman2 = clock(); //normal islemin bitim noktasi
//getch(); //olmasi gereksiz bu yuzden kaldirildi...
cout<<endl<<endl<<"Herhangi bir tusa basiniz";
getch();
clrscr();
cout<<endl<<endl<<cikti<<" adet asal sayi bulundu..."<<endl; //bulunan asallarin sayisi
cout<<"Bu islem :"<<(zaman2-zaman1)/CLOCKS_PER_SEC<<" saniye surdu"<<endl<<endl<<endl; //hesaplanma suresi
cout<<"Devam etmek icin bir tusa basiniz..."<<endl;
gsayi=-1;
getch();
}
}
//---------------------------------------------------------------------------
int main()
{
giris();
kontrol();
return 0;
}
//---------------------------------------------------------------------------
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
c/c++ ile konsol da imleci degistiren kod ornegi

__________________________________________________ _________
#include <conio.h>

int main( )
{
// tell the user what to do
clrscr();
cputs("Press any key three times.\n\r");
cputs("Each time the cursor will change shape.\n\r");

gotoxy(1,5); // show a solid cursor
cputs("Now the cursor is solid.\n\r");
_setcursortype(_SOLIDCURSOR);

while(!kbhit()) {}; // wait to proceed
getch();


gotoxy(1,5); // remove the cursor
cputs("Now the cursor is gone.");
clreol();

gotoxy(1,6);
_setcursortype(_NOCURSOR);

while(!kbhit()) {}; // wait to proceed
getch();


gotoxy(1,5); // show a normal cursor
cputs("Now the cursor is normal.");
clreol();
gotoxy(1,6);
_setcursortype(_NORMALCURSOR);

while(!kbhit()) {}; // wait to proceed
getch();

clrscr();
return(0);
}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
2'den büyük her çift sayı iki asal sayının toplamı şeklinde yazılabilir.Buna göre klavyeden girilen 2'den büyük bir çift sayının asal toplayanlarını bulan program;
C/C++

#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
int i,j,N,s,e,x,k,z,A[100000];float d;
printf("==Girilen Sayinin Asal Toplayanlarini Bulan Program==\n");
printf("2 den buyuk bir cift sayi giriniz=");scanf("%d",&N);
x=0;
for(i=2;i<=N;i++){s=0;
for(j=1;j<=i;j++){d=(float)i/j;e=floor(d);
if(d==e) s++;}
if(s==2) {x++;A[x]=i;}
}
printf("===%d'in asal toplayanlari===\n",N);
for(k=1;k<=x;k++){
for(z=k;z<=x;z++){if(A[z]+A[k]==N) printf("%d--%d\n",A[k],A[z]);}
}
getch();return 0;
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Öklid Algoritması İle En Büyük Ortak Bölen Bulma;("C")
#include<stdio.h>
#include<conio.h>
#include<math.h>

main()
{
int a,b,buyuk,kucuk,kalan;
printf("birinci sayiyi giriniz...");scanf("%d",&a);
printf("ikinci sayiyi giriniz...");scanf("%d",&b);
if(b>a){buyuk=b;kucuk=a;}
else { kucuk=b;buyuk=a;}
if(kucuk==0) printf("Obeb=%d",buyuk);
else if(buyuk%kucuk==0) printf("Obeb=%d",kucuk);
else{
while(buyuk%kucuk!=0) {kalan=buyuk%kucuk;buyuk=kucuk;kucuk=kalan;}
printf("Obeb=%d",kalan);

}
getch();return 0;


}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Girilen bir cümlede veya kelimedeki harfleri ve sayılarını sırayla yazdıran program..("C");
#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char A[255],B[255];
int x,i,j,s,y;
printf("Kelimeyi giriniz...");gets(A);
x=0;
B[0]=A[0];
for(i=1;i<strlen(A);i++){s=0;
for(j=i-1;j>=0;j--) {if(A==A[j]) {s++;break;}}
if(s==0) { x++;B[x]=A;}
}
for(i=0;i<x+1;i++){y=0;
for(j=0;j<strlen(A);j++){
if(B==A[j]) y++;}
if(B!=' ') printf("%c==>%d\n",B,y);
}
getch();return 0;
}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Herhangi bir tarih giriyosunuz gün,ay,yıl olarak daha sonra o tarihten kaç gün sonraki tarihe ulaşmak istiyosanız o tarihi buluyo.("C");
#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
int A[12]={31,28,31,30,31,30,30,31,30,31,30,31};
int gun,ay,yil,gun_sonra,i;
printf("Gunu giriniz...");scanf("%d",&gun);
printf("Ayi giriniz...");scanf("%d",&ay);
printf("Yili giriniz...");scanf("%d",&yil);
while(gun>31||gun<1) {printf("Gunu yanlis girdin bir daha gir...");scanf("%d",&gun);}
while(ay>12||ay<1) {printf("Ayi yanlis girdin bir daha gir...");scanf("%d",&ay);}
printf("Kac gun sonraki tarih bulunsun...");scanf("%d",&gun_sonra);
for(i=1;i<=gun_sonra;i++){if(yil%4==0) A[1]=29;else A[1]=28;
gun=gun+1; if(gun>A[ay-1]) { ay++;gun=1;}
if(ay>12) {ay=1;yil++;}
}
printf("%d/%d/%d",gun,ay,yil);
getch();return 0;
}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
===Asal Çarpanlara Ayrılış===

Fonksiyonlara yeni giriş yapanlar için güzel bir örnek..

#include<stdio.h>
#include<conio.h>
#include<math.h>
int N,d=2;
int asal_mi()
{
int z,j;
for(j=2;j<=floor(sqrt(N));j++) {z=0;if(N%j==0) {z++;break;} }
if(z==0) return 1;
else return 0;
}
void bir_sonraki_asal()
{
int y,i;
while(1) {d++;y=0;
for(i=2;i<=floor(sqrt(d));i++){ if(d%i==0) {y++;break;} }
if(y==0) break;}
}

main()
{
int x,sinama,k;
int A[100];
x=0;
do{printf("Sayiyi Giriniz..");scanf("%d",&N);
if(N<=1) printf("Girdiginiz sayi 1 den buyuk olmali\n");}while(N<=1);
while(1) {
while(N%d==0) {x++;A[x]=d;N=N/d;}
if(N==1) break;
sinama=asal_mi();
if(sinama==1) {x++;A[x]=N;break;}
bir_sonraki_asal();
}
printf("==Sayinin Asal Carpanlarina Ayrilisi==\n");
for(k=1;k<x;k++) printf("%d*",A[k]);
printf("%d",A[x]);
getch();return 0;
}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
===Sayısal Loto===

#include<stdio.h>
#include<conio.h>
#include<time.h>
#include<stdlib.h>
main()
{
int tahmin[6],loto[6];
int i,j,x,y,z,w;
srand(time(NULL));
i=0;
z=0;
while(1)
{
loto=rand()%49+1;
for(j=i-1;j>=0;j--) {w=0;
if(loto==loto[j]) {w++;break;}
}
if(w==0) {z++;i++;}
if(z==6) break;
}


printf("===Sayisal Loto===\n");x=0;
for(i=0;i<6;i++) { printf("%d. tahmininizi giriniz...",i+1);scanf("%d",&tahmin);}
for(i=0;i<6;i++){
for(j=0;j<6;j++){
if(tahmin==loto[j]) {x++;break;}
}
}
printf("%d dogru tahminde bulundunuz..\n",x);
printf("***Loto Sayilari***\n");
for(i=0;i<5;i++){
for(j=i+1;j<6;j++){if(loto[j]<loto) {y=loto;loto=loto[j];loto[j]=y;}
}
}
for(i=0;i<6;i++) printf("=%d=\n",loto);
getch();return 0;
}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
c dili _ sayı tahmın oyunu

/*guess number game*/
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
/*part1*/
int main()
{
int guess,number;
char k;
/*answer to play again*/

do
{

srand((unsigned)time(NULL));
number=rand() %1000;
printf("Firstly you are contestant and computer is yor rival:\n");
printf("computer hold a number which is between 1 and 1000\n");
printf("try to find this number by guessing\n");

int c=0;
/*counter1*/
for ( ;guess!=number
wink.gif

{
printf("your guess:");
scanf("%d",&guess);
fflush(stdin);
c=c+1;
if(guess<number)printf("number is greater than your guess!\n");
else if(guess>number)printf("number is smaller than your guess!\n");
else printf("CONGRATULATIONS!!!You know the number at your %d guess\n",c);
}
/*part2*/

printf("now it's computer's turn\n");
printf("you are rival and the computer is contestant\n");
char answer;
int a=0;
/*counter2*/
int low=0;
int high=1000;
int mid;
do
{
mid=(low+high)/2;
printf ("computer's guess:%d",mid);
printf ("Is number greater, smaller or equal?<G/S/E>:");
scanf("%c*c", &answer);
fflush(stdin);
a=a+1;
if(answer=='S')(high=mid);
if(answer=='G') (low=mid);
if(answer=='E') printf("CONGRUTULATION!!!computer know the number at it's %d guess!",a);
}
while(answer!='E');
if(c<a)printf("you are the WINNER, computer is the LOSER..");
if(c>a)printf("computer is the WINNER, you are the LOSER..");

printf ("do you want to play again?<y/n>:");
scanf("%c",&k);
}
while(k=='y');
return 0;
}
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
basicte asal sayıları hesaplayan bir fonksiyon
function asalsayılar(sonrakam)
dim asal(sonrakam/4)
asal(1)=2
asal(2)=3
s=2
n=3
while n<sonrakam-2
n=n+2 : el=1
while el>0 and n>asal(el)^2
el=el+1
if int(n/asal(el))*asal(el)=n then el=0
end while
if el=0 then s=s+1:asal(s)=n
endwhile
endfunction
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
;asal sayılar
function asal(sonrakam)
dim asal(sonrakam/4)
asal(1)=2
asal(2)=3
s=2
for n=5 to sonrakam step 2
--el=2
--while el>0
----if int(sqrt(n))<asal(el) then
------el=0
------s=s+1
------asal(s)=n
----elseif int(n/asal(el))*asal(el)=0 then
------el=0
----else
------el=el+1
----endif
next
endfunction
__________________
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
scheme de sayi tahmini
Kod:
(define rasgele (+ (random 99) 1))

(define (cikis-mesaji deneme)
  (cond
    [(< deneme 5) (string-append "Viss, " (number->string deneme) " seferde bildin!")]
    [(> deneme 8) (string-append "Cus!Ancak " (number->string deneme) " seferde biebildin!")]
    [else (string-append (number->string deneme) " seferde bildin!")]))
  
(define (tahmin hedef deneme)
  (define thmn (string->number (read-line)))
    (cond
      [(= thmn hedef) (write cikis-mesaji deneme)]
      [(< thmn hedef) (and (write "Cik cik") (tahmin hedef (+ deneme 1)))]
      [(> thmn hedef) (and (write "In in") (tahmin hedef(+ deneme 1)))]))
    
(write "0-100 arasi bi sayi gir")
(tahmin rasgele 0)
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
ruby de yazdığım merkez bankasından döviz kurlarını gösteren zıbıdık.eğer çapraz kur olayını da ekleyebilirsem tam süper olacak
Kod:
require 'rubygems'
require 'hpricot'
require 'open-uri'

class Kur < Struct.new(:kod, :isim,:birim, :alis, :satis)
    def print
        puts "#{birim} #{isim}(#{kod})"
        puts "Alis Fiyati: #{alis} YTL"
        puts "Satis Fiyati: #{satis} YTL"
        puts
    end
end

class KurOkuyucu
    def initialize
        begin
            xml = Hpricot open("http://tcmb.gov.tr/kurlar/today.xml")
        rescue SocketError
            puts "Baglanti Hatasi!"
            exit
        end
        root = xml.at :tarih_date
        @tarih = root[:tarih]
        
        @kurlar = []
        (root/:currency).each do |c|
            kod = c[:kod]
            isim = (c/:isim).inner_text
            alis = (c/:banknotebuying).inner_text
            birim = (c/:unit).inner_text
            satis = (c/:banknoteselling).inner_text
            unless alis.empty? or satis.empty?
                @kurlar << Kur.new(kod,isim,birim,alis,satis)
            end
        end
    end
    def kur?(kod)
        kodlar = []
        @kurlar.each{ |k| kodlar << k.kod }
        kodlar.include? kod
    end
    
    def print_all
        print_header
        @kurlar.each { |c| c.print }
    end
    
    def print kodlar
        print_header
        kodlar.each do |kod|
            kur = (@kurlar.select{ |k| k.kod == kod }).first
            kur.print
        end
    end
    def print_codes
        @kurlar.each do |k|
            puts "#{k.kod} => #{k.isim}"
        end
    end
    def print_header
        puts "#{@tarih} Tarihli Doviz Kurlari"
        puts "================================"
    end
end

def parse_argv(okuyucu)
    if ARGV.empty?
        return :print_all,[]
    end
    if ARGV[0] == "kodlar"
        return :kodlar, []
    end
    yardim = %w( yardim help ? )
    if yardim.include?(ARGV[0])
        return :help, []
    end
    yazilacak = []
    ARGV.each do |a|
        kod = a.upcase
        if kod =~ /[A-Z]{3}/ and okuyucu.kur?(kod)
            yazilacak << kod
        end
    end
    if yazilacak.empty?
        return :print_all, []
    end
    return :print, yazilacak
end

if __FILE__ == $0
    okuyucu = KurOkuyucu.new
    gorev, args = parse_argv(okuyucu)
    
    case gorev
        when :help
            puts "Yardim yok simdilik!"
        when :kodlar
            okuyucu.print_codes
        when :print
            okuyucu.print(args)
        when :print_all
            okuyucu.print_all
    end
end
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
ruby'de caching'i olan faktoriyel ve fibonacci sayilari
Kod:
require 'singleton'

class Factorial < Array
  include Singleton
  
  def initialize
    super
    self[0] = 1
  end
  
  def factorial(n)
    self[n] ||= n*factorial(n-1)
  end
end

def fact n
  Factorial.instance.factorial n
end

class Fibonacci < Array
  include Singleton

  def initialize
    super
    self[0], self[1] = 0, 1
  end
  def fibonacci n
    self[n] ||= fibonacci(n-1) + fibonacci(n-2)
  end
end

def fib(n)
  Fibonacci.instance.fibonacci n
end
[
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
ruby'de oldukça basit bir ascii shift cipher kıracağı (hackthissite'taki programming challenge 11 için yazmıştım)
Kod:
puts ARGV[0].split(/\D/).map{|x|(x.to_i-ARGV[1].to_i).chr}.join
biraz fazla mı kısa oldu ne ^^ bir iki tane daha tek satırlık örnek yazayım en iyisi
dosyadaki karakter sayısı
Kod:
puts File.read(ARGV[0]).length
sözcük sayısı
Kod:
puts File.read(ARGV[0]).split(/\s+/).length

satır sayısı (boş satırları saymadan)
Kod:
puts File.read(ARGV[0]).split(/\n/).reject{ |x| x.strip.empty? }.length

bir dosyadaki her satırı numaralayarak ekrana yazdırır
Kod:
File.readlines(ARGV[0]).each_with_index{|l,i| puts "#{i+1}: #{l}"}

bir klasördeki belirtilen uzantıdaki dosyaları listeler
Kod:
Dir[File.join(ARGV[0],"*.#{ARGV[1]}")].each{|x| puts x}

bir klasördeki belirtilen uzantıdaki dosyaları(klasör belirtilmese de olur) ve boyutlarını listeler, boyutlarına göre sıralanmış olarak
Kod:
Dir.glob(ARGV.length == 1 ? "*.#{ARGV[0]}" : File.join(ARGV[0],"*.#{ARGV[1]}")).sort_by{|x| File.read(x).length}.reverse.each{|x| puts "#{x} => #{File.read(x).length}"}
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
rubyquiz #6 => quizini çözen şey. tamamen kendim yazdım. unit testleriyle falan da birlikte.

node.rb:
Kod:
require 'gedcom'
require 'gedcom_node'
require 'xml_node'
 
class Gedcom::Node
  def self.new(text, opts={})
    d = REXML::Document.new text
    if d.root.nil?
      return Gedcom::GedcomNode.new text
    else
      return Gedcom::XmlNode.new text, opts[:level]
    end
  end
end

node_test.rb:
Kod:
require "test/unit"
require "node"

class Gedcom::NodeTest < Test::Unit::TestCase
  def setup
    @gedcom = Gedcom::Node.new "1 ASD pwn"
    @xml = Gedcom::Node.new "<asd>pwn</asd>"
  end
  def test_gedcom_node
    assert_instance_of Gedcom::GedcomNode, @gedcom
  end
  def test_xml_node
    assert_instance_of Gedcom::XmlNode, @xml
  end
end

gedcom_node.rb:
Kod:
require 'level_error'
require 'builder'

class Gedcom::GedcomNode
  attr_reader :level 
  attr_reader :id, :identified 
  attr_reader :tag, :data
  attr_accessor :children
  
  def initialize(text)
    @fulltext = text
    validate
    @children = []
    fields = @fulltext.split
    @level = fields.first.to_i
    tag_or_id = fields[1]
    if tag_or_id[0].chr == "@" and tag_or_id[-1].chr == "@"
      @id = tag_or_id
      @identified = fields[2].downcase
    else
      @tag = tag_or_id.downcase
      @data = fields[2..-1].join " "
    end
  end
  
  def append_child(node)
    unless node.level - @level == 1
      raise LevelError, "Levels invalid! child of a node's level should be one morer than the parent!"
    end
    @children << node
  end
  alias << append_child
  
  def build(builder)
    unless valid?
      raise "GEDCOM invalid!"
    end
    if @tag
      unless @children.empty?
        builder.__send__(@tag,:text => @data) do |b| 
          @children.each { |c| c.build(b) }
        end
      else
        builder.__send__(@tag,@data)
      end
    elsif @id
      unless @children.empty?
        builder.__send__(@identified, :id => @id) do |b|
          @children.each { |c| c.build(b) }
        end
      else
        builder.__send__(@identified, :id => @id)
      end
    end
  end
  
  def to_xml(indent=2)
    builder = Builder::XmlMarkup.new(:indent => indent)
    build(builder)
  end
  alias to_s to_xml
  
  def valid?
    @valid
  end
  def invalid?
    !valid?
  end
  
  private
  
  def validate
    if @fulltext.strip =~ /^\d+\s+@?\S+@?\s.*$/
      @valid = true
    else
      @valid = false
    end
  end
end

gedcom_node_test.rb:
Kod:
require "test/unit"
require 'node'

class Gedcom::GedcomNodeTest < Test::Unit::TestCase
  def setup
    super
    @id = Gedcom::Node.new "0 @T1@ INDI"
    @tag = Gedcom::Node.new "1 NAME I. C. Wiener"
    @deep = Gedcom::Node.new "2 SURN Wiener"
    @invalid = Gedcom::Node.new "2 invalid"
  end
  
  def test_valid
    assert @id.valid?
  end
  
  def test_invalid
    assert @invalid.invalid?
  end
  
  def test_level
    assert_equal 0, @id.level
    assert_equal 1, @tag.level
  end
  
  def test_tag
    assert_not_nil @tag.tag
    assert_not_nil @tag.data
    assert_nil @tag.id
    assert_nil @tag.identified
  end
  
  def test_id
    assert_not_nil @id.id
    assert_not_nil @id.identified
    assert_nil @id.tag
    assert_nil @id.data
  end
  
  def test_tag_and_data
    assert_equal "name", @tag.tag
    assert_equal "I. C. Wiener", @tag.data
  end
  
  def test_id_and_identifier
    assert_equal "@T1@", @id.id
    assert_equal "indi", @id.identified
  end
  
  def test_child
    @id << @tag
    assert_equal 1, @id.children.length
  end
  
  def test_invalid_child
    assert_raise LevelError do 
      @id << @deep
    end
  end
  
  def test_to_xml_without_child
    assert_equal @deep.to_xml.strip, "<surn>Wiener</surn>"
  end
  
  def test_to_xml_with_child
    @tag << @deep
    assert_equal @tag.to_xml.gsub(/\s+/, " ").strip, "<name text=\"I. C. Wiener\"> <surn>Wiener</surn> </name>"
  end
  
  def test_with_id
    @id.children = []
    assert_equal @id.to_xml.strip, "<indi id=\"@T1@\"/>"
  end
end

xml_node.rb:
Kod:
require 'rexml/document'

class Gedcom::XmlNode
  attr_reader :level 
  attr_reader :id, :identified 
  attr_reader :tag, :data
  attr_accessor :children
  attr_reader :root
  
  def initialize(text, level)
    @fulltext, @level = text, level
    @root = REXML::Document.new(text).root
    validate
    @children =[]
    @root.elements.each do |e|
      @children << Gedcom::Node.new(e.to_s)
    end
    if @root.attribute "id"
      @id = @root.attribute("id").value
      @identified = @root.name
    else
      @tag = @root.name
      @data = @root.text || @root.attribute("text")
    end
  end
  
  def level=(l)
    unless l.nil?
      @level = l
      validate
    end    
  end
  
  def valid?
    @valid
  end
  def invalid?
    !valid?
  end
  
  def has_elements?
    @root.has_elements?
  end
  alias has_children? has_elements?
  
  def add_element(element)
    @children << element
    @root.add_element element.root
  end
  alias << add_element
  
  def to_gedcom
    if invalid?
      raise "Invalid for gedcom output, needs to specify level"
    end
    if has_elements?
      res = [to_gedcom_line]
      @children.each do |c|
        c.level = @level + 1
        res << c.to_gedcom
      end
      res.join "\n"
    else
      to_gedcom_line
    end
  end
  alias to_s to_gedcom
  
  
  private
  def to_gedcom_line
    if @tag
      "#{@level} #{@tag.upcase} #{@data}"
    elsif @id
      "#{@level} #{@id.upcase} #{@identified}"
    end
  end
  def validate
    @valid = !@level.nil?
  end
end

xml_node_test.rb:
Kod:
require "test/unit"
require 'node'

class Gedcom::XmlNodeTest < Test::Unit::TestCase
  def setup
    @valid = Gedcom::Node.new("<dummy>valid</dummy>", :level => 3)
    @invalid = Gedcom::Node.new("<dummy>invalid</dummy>")
    @id = Gedcom::Node.new("<indi id=\"@as@\"/>")
    @child = Gedcom::Node.new("<p><c>asd</c></p>")
    @parent = Gedcom::Node.new("<par />")
    @with_child = Gedcom::Node.new("<p id=\"@aa@\"><c>dummy</c></p>", :level => 2)
  end
  
  def test_valid
    assert @valid.valid?
  end
  
  def test_invalid
    assert @invalid.invalid?
  end
  
  def test_id
    assert_not_nil @id.id
    assert_not_nil @id.identified
    assert_nil @id.tag
    assert_nil @id.data
  end
  
  def test_tag
    assert_not_nil @valid.tag
    assert_not_nil @valid.data
    assert_nil @valid.id
    assert_nil @valid.identified
  end
  
  def test_id_and_identified
    assert_equal "@as@", @id.id
    assert_equal "indi", @id.identified
  end
  
  def test_tag_and_data
    assert_equal "dummy", @valid.tag
    assert_equal "valid", @valid.data
  end
  
  def test_children
    assert @child.has_children?
    assert !@parent.has_children?
    @parent << @child
    assert @parent.has_children?
  end
  
  def test_invalid_to_gedcom
    assert_raise RuntimeError, "Invalid for gedcom output, needs to specify level" do
      @invalid.to_gedcom
    end
  end
  
  def test_to_gedcom_no_children
    assert_equal "3 DUMMY valid", @valid.to_gedcom
  end
  
  def test_to_gedcom_with_children
    assert_equal "2 @AA@ p 3 C dummy", @with_child.to_gedcom.gsub(/\s+/, " ")
  end
end

gedcom_tree.rb:
Kod:
require 'gedcom_node'
require 'rexml/document'

class GedcomTree
  def initialize(file)
    if file.respond_to? :read
      file = file.read    
    end
    @nodes = []
    @allnodes = []
    lines = file.split "\n"
    lines.each do |l|
      line = GedcomNode.new(l)
      @allnodes << line
      if line.level == 0
        @nodes << line
      else
        parent = @allnodes.select{ |n| n.level == line.level - 1 }[-1]
        parent << line
      end
    end
  end
  
  def to_xml(indent = 2)
    builder = Builder::XmlMarkup.new(:indent => indent)
    builder.gedcom do |b|
      @nodes.each do |n|
        n.build(b)
      end
    end
  end
end
aa bunun unit testi yok muş!! inanamıyorum!!

level_error.rb:
Kod:
class LevelError < StandardError
end

gedcom.rb:
Kod:
module Gedcom
end
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
ruby ile lyricwiki.org'dan şarkı sözleri alan zıbıdık
Kod:
require 'open-uri'
require 'cgi'
require 'hpricot'

usage = "lyrics.rb artist title"
puts usage unless ARGV.length == 2

artist, title = ARGV.map{|x| CGI.escape(x).gsub(/\+(\w)/){|m| "_" + m[1].chr.upcase}.sub(/(\w)/){|m| m.upcase}}
file = Hpricot(open("http://lyricwiki.org/#{artist}:#{title}"))
div = (file/".lyricbox")[0]
begin
  puts div.innerHTML.gsub(/\<br \/\>/,"\n").gsub(/<(.|\n)*?>/,"")
rescue 
  puts "No lyrics found"
end
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
brainfuck kodunu alıp c ye çevirip gcc ile(bulamazsa mingw32 ile) derliyor. ruby ile yazılmış tabi :D
Kod:
require 'erb'

Commands = {
  "+" => "++*ptr;", 
  "-" => "--*ptr;", 
  ">" => "++ptr;",
  "<" => "--ptr;",
  "." => "putchar(*ptr);",
  "," => "*ptr = getchar();",
  "[" => "while(*ptr){",
  "]" => "}"
}
def translate(contents)
  contents.chars.select{|c| Commands.has_key? c}.map{|c| Commands[c]}.join " "
end
def compile(filename, commands)
  return if commands.empty?
  print `#{commands.shift} #{filename}.c`
rescue
  compile(filename, commands)
end

template = ERB.new <<-EOF
#include<stdio.h>
main(){
  unsigned char data[30000];
  char *ptr = data;
  <%= translate(File.read("#{ARGV[0]}.b")) %>
  getchar();
}
EOF

File.open("#{ARGV[0]}.c",'w'){|f| f.puts template.result(binding)}
compile(ARGV[0],%w{gcc mingw32})
 

DiziEvi

Site Sahibi
Yönetici
Admin
Kayıtlı Kullanıcı
Katılım
25 Aralık 2024
Mesajlar
39,027
Tepkime puanı
11,285
Puanları
393,787
Yaş
66
Konum
Türkiye Ankara
Web sitesi
www.dizievi.net
Kod:
require 'rubygems'
require 'open-uri'
require 'cgi'
require 'hpricot'
require 'id3lib'

usage = "lyrics.rb filename"
unless ARGV.length == 1
  puts usage
  exit
end

def lyrics(title,artist)
    file = Hpricot(open("http://lyricwiki.org/#{artist}:#{title}"))
    div = (file/".lyricbox")[0]
    begin
        div.innerHTML.gsub(/\<br \/\>/,"\n").gsub(/<(.|\n)*?>/,"")
    rescue 
        puts "No lyrics found"
        nil
    end
end

def escape x
  CGI.escape(x).gsub(/\+(\w)/){|m| "_" + m[1].chr.upcase}.sub(/(\w)/){|m| m.upcase}
end

tag = ID3Lib::Tag.new(ARGV[0])
artist,title = escape(tag.artist), escape(tag.title)
ly = lyrics title, artist
tag.lyrics = ly
tag.update!
 
shape1
shape2
shape3
shape4
shape7
shape8
Üst