アニメ!アニメ!

2018年1月26日金曜日

【ゲーム製作入門】C-C++で簡単なRPGを作る①【DXライブラリ】

【ゲーム製作入門】C-C++で簡単なRPGを作る①【DXライブラリ】
http://nut-softwaredevelopper.hatenablog.com/entry/2015/05/03/183027
【ゲーム製作入門】C-C++で簡単なRPGを作る②【DXライブラリ】
http://nut-softwaredevelopper.hatenablog.com/entry/2015/05/04/012416
【ゲーム製作入門】C-C++で簡単なRPGを作る③【DXライブラリ】
http://nut-softwaredevelopper.hatenablog.com/entry/2015/05/11/174719
【ゲーム製作入門】C-C++で簡単なRPGを作る④【DXライブラリ】 - ここまで ..-
http://nut-softwaredevelopper.hatenablog.com/entry/2015/05/11/205727

2018年1月23日火曜日

C++ ラベルとbreak文

#include <iostream>
using namespace std;

int main()
{
int n;
cout << "整数を入力せよ:";
cin >> n;

switch (n){
case 0: cout << "A";
cout << "B";
break;
case 2: cout << "C";
case 5: cout << "D";
break;
case 6:
case 7:cout << "E";
break;
default:cout << "F";
break;
}
cout << "\n";

return 0;
}

C++ switch文

#include <iostream>
using namespace std;

int main()
{
int hand;

cout << "手を選んでください(0・・・グー/1・・・チョキ/2・・・パー):";
cin >> hand;

switch (hand){
case 0: cout << "グー\n"; break;
case 1: cout << "チョキ\n"; break;
case 2: cout << "パー\n"; break;
}
return 0;
}

C++ 二択条件演算子

#include <iostream>
using namespace std;

int main()
{
int a, b;

cout << "整数a:"; cin >> a;
cout << "整数b:"; cin >> b;


int min;
if (a < b)
min = a;
else
min = b;

cout << "小さいほうの値は" << min << "です。\n";

return 0;
}

C++ 論理演算子

#include <iostream>
using namespace std;

int main()
{
int month;
cout << "季節を求めます。\n何月ですか:";
cin >> month;

if (month >= 3 && month <= 5)
cout << "それは春です。\n";
else if (month >= 6 && month <= 8)
cout << "それは夏です。\n";
else if (month >= 9 && month <= 11)
cout << "それは秋です。\n";
else if (month == 12 || month == 1 || month == 2)
cout << "それは冬です。\n";

return 0;
}

C++ 論理否定演算子

#include <iostream>
using namespace std;

int main()
{
int n;

cout << "整数:";
cin >> n;

if (!n)
cout << "その値はゼロです。\n";
else
cout << "その値はゼロではありません。\n";
return 0;
}

C++ 等価演算子

#include <iostream>
using namespace std;

int main()
{
int a, b;

cout << "整数a:"; cin >> a;
cout << "整数b:"; cin >> b;

if (a == b)
cout << "二つの値は等しいです。\n";
else
cout << "二つの値は等しくありません\n";

return 0;
}