Last active
June 15, 2017 06:35
-
-
Save lablabkun/ec5a9bca376d2579f37955b8632d0eed to your computer and use it in GitHub Desktop.
構造体の使用例
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 <iostream> | |
#include <string> | |
// robotという構造体を作成する | |
struct robot | |
{ | |
std::string color; // ロボットの色 | |
int button; // ロボットのボタンの数 | |
int arm; // ロボットの腕の数 | |
}; | |
int main() | |
{ | |
robot hitogata; // 人型ロボットについて | |
robot osouji; // お掃除ロボットについて | |
// 人型ロボットについての情報を入力 | |
hitogata.color = "green"; // 人型ロボットの色 | |
hitogata.button = 4; // 人型ロボットのボタンの数 | |
hitogata.arm = 2; // 人型ロボットのボタンの数 | |
// お掃除ロボットについての情報を入力 | |
osouji.color = "gray"; // お掃除ロボットの色 | |
osouji.button = 4; // お掃除ロボットのボタンの数 | |
osouji.arm = 2; // お掃除ロボットの腕の数 | |
std::cout << "人型ロボットのボタンの数は" << hitogata.button << "だよ" << std::endl; | |
std::cout << "お掃除ロボットの色は" << osouji.color << "だよ" << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment