開発環境
- OS X Lion - Apple(OS)
- TextWrangler(Text Editor) (BBEditの無料、light版)
- 言語: C
- コンパイラ: UNIX ccコンパイラ (汎用UNIX)
『実践プログラミング 第3版』 (Steve Oualline (著)、 望月 康司 (監修) (翻訳)、 谷口 功 (翻訳)、 オライリー・ジャパン、1998年、ISBN978-4900900646) I部(基礎編)の4章(基本的な宣言および式)4.13(プログラミング実習)実習4-4を解いてみる。
実習4-4.
コード(TextWrangler)
#include <stdio.h>
#include <string.h>
int main(){
char h1[6];
char h2[6];
char e1[6];
char e2[6];
char l1[6];
char l2[6];
char o1[6];
char o2[6];
strcpy(h1,"* *");
strcpy(h2,"*****");
strcpy(e1,h2);
strcpy(e2,"* ");
strcpy(l1,e2);
strcpy(l2,h2);
strcpy(o1," * ");
strcpy(o2,"* *");
int i,j;
printf("%s %s %s %s %s\n",h1,e1,l1,l1,o1);
printf("%s %s %s %s %s\n",h1,e2,l1,l1,o2);
printf("%s %s %s %s %s\n",h1,e2,l1,l1,o2);
printf("%s %s %s %s %s\n",h2,e1,l1,l1,o2);
printf("%s %s %s %s %s\n",h1,e2,l1,l1,o2);
printf("%s %s %s %s %s\n",h1,e2,l1,l1,o2);
printf("%s %s %s %s %s\n",h1,e1,l2,l2,o1);
入出力結果(Terminal)
$ cc -g -o sample sample.c $ ./sample * * ***** * * * * * * * * * * * * * * * * * ***** ***** * * * * * * * * * * * * * * * * * * * * ***** ***** ***** * $
0 コメント:
コメントを投稿