if文

フォーラム(掲示板)ルール
フォーラム(掲示板)ルールはこちら  ※コードを貼り付ける場合は [code][/code] で囲って下さい。詳しくはこちら
anz

if文

#1

投稿記事 by anz » 12年前

学校の課題でユーザーに数字を入力させて1なら四角を、2なら円を表示し、それ以外ならexitで終了させる
というものなんだが、それ以外のexitでの終了ができないから助けを要請…

自分で書いたものは

コード:

#include <stdio.h> 
#include <stdlib.h> 
#include <eggx.h> 


main() { 

int quwstion;//1,0の読み込み 
int win; 
int height;//縦 間隔 
int widch;//横 間隔 
int n = 1;//色番号の変数 
double x ,y;//線の長さ、太さ 

printf("Please input 1 or 2.\n");//ユーザー入力 
scanf("%d", &quwstion); 

if (quwstion != 1 && quwstion != 2) 
break; 

win=gopen(400,400);//窓表示 

winname(win, "sample 1");//窓の名前 

x=10.0;//xの初期化 

else if (quwstion == 1) {//1:四角を描くとき 

for (widch = 0; widch < 38; widch++) { 
x=widch*15.0 + 10.0;//線と線の幅を指定 

for(height=0; height<38; height++ ) { 

newpen(win, n); // 描画する色を設定 
y=height*15.0 + 10.0;//線と線の幅を指定 
fillrect(win, x, y, 5.0, 5.0);//線を塗る 
n++;//カウントアップ 

if (n > 15)//黒の線を描かない 
n = 1; 
} 
} 
} 
else {//2:円を描くとき 
for (widch = 0; widch < 38; widch++) { 
x=widch*15.0 + 10.0;//線と線の幅を指定 

for(height=0; height<38; height++ ) { 

newpen(win, n); // 描画する色を設定 
y=height*15.0 + 10.0;//線と線の幅を指定 
fillarc(win, x, y, 5.0, 5.0, 0.0, 360.0, 1);//線を塗る 
n++;//カウントアップ 

if (n > 15)//黒の線を描かない 
n = 1; 
} 
} 
} 
ggetch(); 
gclose(win); 

exit(0); 
}

anz

Re: if文

#2

投稿記事 by anz » 12年前

事故解決
騒がして申し訳ないです…

閉鎖

“C言語何でも質問掲示板” へ戻る