Building a rectengular shape wtih C Programming Language
/* * Rectangular.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 shortedge,longedge, space , i,j,k; printf ("short edge ="); scanf("%d",&shortedge); printf("\n"); printf("long edge ="); scanf("%d", &longedge); printf("\n"); space=(longedge-2)*2+1; shortedge=shortedge-2; for (i=0;i<longedge;i++)//This is TOP Edge { printf("* "); } printf("\n"); for(j=0;j<shortedge;j++)//Here is MITTLE { printf ("*"); for(k=0;k<space;k++) { printf(" "); } printf("*\n"); } for (i=0;i<longedge;i++)//This is BOTTOM edge {printf("* ");}printf("\n"); system("PAUSE"); return 0; }
i must explain a bit, i didn’t write any control to check is longedge
true or false, you can add
while (shortedge<longadge)
i put space between * *, you can delete it, but if you,
you must modify a bit,
First Change
{printf("* ");}printf("\n");
to
{printf("*");}printf("\n");
Second Change
space=(longedge-2)*2+1;
to
space=(longedge-2);
it’s all, i hope it can be useful for you, Hasan ibrahim


ç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:)
@nihal. Olmadı ekranda 3D ye başlayalım :p fakat boyle fikir veriyosunuz, sonra yapmadan uykumuz gelmiyor