2014年1月14日火曜日

開発環境

C++実践プログラミング (スティーブ オウアルライン (著)、Steve Oualline (原著)、Steve Oualline(原著)、望月 康司(翻訳)、クイープ(翻訳) 、オライリー・ジャパン)のⅠ部(基礎)の5章(配列、修飾子、数値の使用)、5.3(データの入力)、設問5-1.を解いてみる。

その他参考書籍

設問5-1.

コード

sample.cpp

#include <iostream>

int height; /* 三角形の高さ (問題のコードでは、このコメントを閉じ忘れている) */
int width;
int area;

int main()
{
    std::cout << "Enter width height? ";
    std::cin >> width >> height;
    area = (width * height) / 2;
    std::cout << "The area is " << area << '\n';
    return (0);
}

入出力結果(Terminal)

$ g++ -g -Wall -osample sample.cpp
$ ./sample
Enter width height? 5 10
The area is 25
$

0 コメント:

コメントを投稿