Skip to content

Instantly share code, notes, and snippets.

@torazuka
torazuka / drill_3.cpp
Created August 19, 2011 18:53
Chapter03_drill_PPPC++
#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.";
@torazuka
torazuka / chapter4_drill.cpp
Created August 24, 2011 11:49
Chapter04_6_drill_PPPC++
#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";
@torazuka
torazuka / chapter4_drill.cpp
Created August 24, 2011 13:43
Chapter04_7_drill_PPPC++
#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;
@torazuka
torazuka / chapter4_8_drill.cpp
Created August 24, 2011 19:55
Chapter04_8_drill_PPPC++
#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;
@torazuka
torazuka / chapter4_9_drill.cpp
Created August 25, 2011 21:59
Chapter04_9_drill_PPPC++
#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;
@torazuka
torazuka / chapter4_10_drill.cpp
Created August 25, 2011 22:11
Chapter04_10_drill_PPPC++
#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;
@torazuka
torazuka / calculator02.cpp
Created September 7, 2011 23:24
Chapter06_drill_PPPC++
//
// 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
@torazuka
torazuka / calculator.cpp
Created September 14, 2011 13:44
Chapter07_drill_PPPC++
/*
> 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.
*/
@torazuka
torazuka / Date.cpp
Created September 19, 2011 07:54
Chapter09_drill01_PPPC++
/*
『ストラウストラップのプログラミング入門』
9章ドリル1(9.4.1バージョン, データだけ持つstruct)
*/
#include "../../std_lib_facilities.h"
struct Date{
int y;
int m;
@torazuka
torazuka / Date.cpp
Created September 19, 2011 07:55
Chapter09_drill02_PPPC++
/*
『ストラウストラップのプログラミング入門』
9章ドリル2(9.4.2バージョン, メンバ関数を持つstruct)
*/
#include "../../std_lib_facilities.h"
struct Date{
int y, m, d; // 年月日
Date(int y, int m, int d); // 日付の有効性を確認して初期化する