Gıda – Web – Teknoloji != Hasanibrahim

C programlama dili ile dikdortgen yapma/çizme

by on Kas.14, 2009, under ANSI C

/*
 
* Dikdortgen.c
 
* * Copyright 2009 Hasanibrahim hasan@ibrahimkozan.com
 
* * This program is free software; you can redistribute it and/or modify
 
* it under the terms of the GNU General Public License as published by
 
* the Free Software Foundation; either version 2 of the License, or
 
* (at your option) any later version.
 
* * This program is distributed in the hope that it will be useful,
 
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
 * GNU General Public License for more details.
 
 * * You should have received a copy of the GNU General Public License
 
* along with this program
 
*/
 
#include <stdio.h>
#include <stdlib.h>
 
int main(int argc, char *argv[])
{
    int kisakenar,uzunkenar, bosluk , i,j,k;
    printf ("kisa kenar =");
    scanf("%d",&kisakenar);
    printf("\n");
    printf("uzun kenar =");
    scanf("%d", &uzunkenar);
    printf("\n");
    bosluk=(uzunkenar-2)*2+1;
    kisakenar=kisakenar-2;
 
 
    for (i=0;i<uzunkenar;i++)//Bu ust kenar
    {
        printf("* ");
    }
 
    printf("\n");
 
    for(j=0;j<kisakenar;j++)//Burası da orta icin
    {
    printf ("*");
    for(k=0;k<bosluk;k++)
    {
                         printf(" ");
    }
    printf("*\n");
    }
 
    for (i=0;i<uzunkenar;i++)//Bu alt kenar
    {printf("* ");}printf("\n");
 
 
 
  system("PAUSE");	
  return 0;
}

Hemen Açıklamaya Geçelim.
Uzun kenar ve kısa kenar kontrolü için ;

 while (shortedge<longadge)

deyimini kullanabilirsiniz.

Karakterler arasına bir boşluk koydum, bunu kaldırmak için
bir kaç ufak düzenleme yapmaniz gerekir.
İlk olarak

 {printf("* ");}printf("\n");

bu deyimi

 {printf("*");}printf("\n");

buna
İkinci olarak

 space=(longedge-2)*2+1;

bu deyimi

 space=(longedge-2);

buna çevirmeniz gerekir.
Hepsi bu kadar
Umarım yararlı olur, Hasan İbrahim


2 Comments for this entry

  • Hasan İbrahim Kozan

    @nihal. Olmadı ekranda 3D ye başlayalım :p fakat boyle fikir veriyosunuz, sonra yapmadan uykumuz gelmiyor :)

  • nihal

    çok harika olmuş elinize sağlık ahhh ahh keşke fonsiyon ve alt menülerle iç içe eşkenar dörtgen,paralkenar,kum saati çizdiren bir programda yazmış olsaydınız:) neyse gerçekçi olup ödeve devam etmek en güzeli sanırım başarılar:)

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...