24 Mayıs 2009 Pazar

C# sayısal loto programı

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace sayısal_loto
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int z = 1;
private void button1_Click(object sender, EventArgs e)
{
z++;
Random sayı = new Random();
int[] dizi = new int[6];

for(int y=0;y<6;y++)
{
int tahmın = sayı.Next() % 49+1;
dizi[y] = tahmın;
for (int u = 0; u <=y-1; u++)
{
if (dizi[y] == dizi[u])
{
dizi[y] = sayı.Next() % 49 + 1;
}
}
}
for (int p = 0; p <6;p++)
{
for (int r = 0; r <6;r++)
{
if (dizi[p] {
int m;
m = dizi[p];
dizi[p] = dizi[r];
dizi[r] = m;
}
}
}
foreach (int eleman in dizi)
{
listBox1.Items.Add(eleman);

}
listBox1.Items.Add("-------"+z+"."+"kolon"+"----------");
}

private void Form1_Load(object sender, EventArgs e)
{
listBox1.Items.Add("------1.kolon------");
}
}
}

C# random sayı uretmek

static void Main(string[] args)
{
Random sayi = new Random();
int rastgele,sayi2;
rastgele = sayi.Next();
sayi2 = rastgele % 10;
Console.WriteLine(sayi2);
}

18 Mayıs 2009 Pazartesi

C de recursive fonksiyon kullanarak fibonacci sayılarının bulunması

#include
#include


int fibo(int x)
{
int a;
if( x<2)
{
return x;
}
else
{
return fibo(x-1)+fibo(x-2);
}
}
int fibo(int);
int main()
{
int b,i;

printf("sayi gir:");
scanf("%d",&b);
for(i=0;i
printf("%d\n",fibo(i));

system("PAUSE");
return 0;
}

Assembly dilinde toplama islemi

XRA A
MOV D,A
MOV D,E

LXI H,2000
MOV A,M
MVI B,FEH
LOOP:

INX H
ADD M

JNC CARY

MOV C,A
MOV A,D
ADI 01H
MOV D,A
MOV A,C

JNC CARRY

INR E

CARRY:
CARY:

DCR B
JNZ LOOP

STA 3005H
MOV A,D
STA 3004H
MOV A,E
STA 3003H
HLT

C de fibonacci sayılarını bulma

#include
#include

void main()
{
int y=1;
long n,i;
long x1=1;
long x2=1;
long toplam;
printf("sayi gir:");
scanf("%d",&n);

for(i=1;i<=n;i++)
{
if(i<3)
{ printf("%d.fibonacci sayisi: ",y++);
printf("%ld\n",x1);


}
else
{

toplam =x1+x2;
x1=x2;
x2=toplam;
printf("%d.fibonacci sayisi: ",y++);
printf("%ld\n",toplam);

}



}

system("PAUSE");
return 0;
}