This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "../../std_lib_facilities.h" // from http://www.stroustrup.com/Programming/ | |
int main(){ | |
cout << ">>>> あなたの名前を入力してください "; | |
string first_name; | |
cin >> first_name; | |
if(cin.fail()){ | |
cout << "input error."; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "../../std_lib_facilities.h" | |
int main(){ | |
int count = 0; | |
double n = 0.0; | |
double max = 0.0; | |
double min = 0.0; | |
cout << "数字を1つ入力する。「|」を入力したら終了する。\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "../../std_lib_facilities.h" | |
int main(){ | |
const string unit_cm = "cm"; | |
const string unit_m = "m"; | |
const string unit_in = "in"; | |
const string unit_ft = "ft"; | |
const double cm_per_m = 100; | |
const double cm_per_in = 2.54; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "../../std_lib_facilities.h" | |
int main(){ | |
const string unit_cm = "cm"; | |
const string unit_m = "m"; | |
const string unit_in = "in"; | |
const string unit_ft = "ft"; | |
const double cm_per_m = 100; | |
const double cm_per_in = 2.54; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "../../std_lib_facilities.h" | |
int main(){ | |
const string unit_cm = "cm"; | |
const string unit_m = "m"; | |
const string unit_in = "in"; | |
const string unit_ft = "ft"; | |
const double cm_per_m = 100; | |
const double cm_per_in = 2.54; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "../../std_lib_facilities.h" | |
// 入力された値をm似変換して保持する。最後に一覧を出す。 | |
int main(){ | |
const string unit_cm = "cm"; | |
const string unit_m = "m"; | |
const string unit_in = "in"; | |
const string unit_ft = "ft"; | |
const double cm_per_m = 100; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// This is example code from Chapter 6.7 "Trying the second version" of | |
// "Software - Principles and Practice using C++" by Bjarne Stroustrup | |
// | |
/* | |
>This file is known as calculator02buggy.cpp | |
> | |
>I have inserted 5 errors that should cause this not to compile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
> calculator08buggy.cpp | |
> Helpful comments removed. | |
> We have inserted 3 bugs that the compiler will catch and 3 that it won't. | |
7章ドリル. this is an answer. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
『ストラウストラップのプログラミング入門』 | |
9章ドリル1(9.4.1バージョン, データだけ持つstruct) | |
*/ | |
#include "../../std_lib_facilities.h" | |
struct Date{ | |
int y; | |
int m; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
『ストラウストラップのプログラミング入門』 | |
9章ドリル2(9.4.2バージョン, メンバ関数を持つstruct) | |
*/ | |
#include "../../std_lib_facilities.h" | |
struct Date{ | |
int y, m, d; // 年月日 | |
Date(int y, int m, int d); // 日付の有効性を確認して初期化する |