mustaphos
MB Üyesi
- Kayıt
- 14 Eylül 2015
- Mesajlar
- 35
- Tepkiler
- 8
- Yaş
- 30
- Meslek
- Öğrenci
- Üniv
- Anadolu University
Merhaba.
Bu program istenen miktarda pascal üçgeni yapar.
İyi çalışmalar.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
float faktoriyel(float fakt);
float kombinasyon(float komb);
void main ()
{
int sayi ;
printf("Please enter an integer : ");
scanf("%d",&sayi);
printf("\n");
printf("\n");
printf("\n");
printf("\n");
kombinasyon(sayi-1);
getch();
}
float faktoriyel (float fakt)
{
float counter,total;
for (counter=1,total=1;counter<=fakt;counter++)
{
total *= counter;
}
return total;
}
float kombinasyon (float komb)
{
float sayac,sonuc,satir,space;
satir=0;
while (satir<=komb)
{
space = 0;
while ( space < komb-satir+1 ) /* While loop for spaces on the left side. */
{
printf("");
space++;
}
sayac=0;
while (sayac<=satir)
{
sonuc =faktoriyel(satir)/(faktoriyel(sayac)*faktoriyel(satir-sayac));
sayac++;
printf("%.f",sonuc);
}
printf("\n");
printf("\n");
printf("\n");
printf("\n");
satir++;
}
}
Bu program istenen miktarda pascal üçgeni yapar.
İyi çalışmalar.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
float faktoriyel(float fakt);
float kombinasyon(float komb);
void main ()
{
int sayi ;
printf("Please enter an integer : ");
scanf("%d",&sayi);
printf("\n");
printf("\n");
printf("\n");
printf("\n");
kombinasyon(sayi-1);
getch();
}
float faktoriyel (float fakt)
{
float counter,total;
for (counter=1,total=1;counter<=fakt;counter++)
{
total *= counter;
}
return total;
}
float kombinasyon (float komb)
{
float sayac,sonuc,satir,space;
satir=0;
while (satir<=komb)
{
space = 0;
while ( space < komb-satir+1 ) /* While loop for spaces on the left side. */
{
printf("");
space++;
}
sayac=0;
while (sayac<=satir)
{
sonuc =faktoriyel(satir)/(faktoriyel(sayac)*faktoriyel(satir-sayac));
sayac++;
printf("%.f",sonuc);
}
printf("\n");
printf("\n");
printf("\n");
printf("\n");
satir++;
}
}