アニメ!アニメ!

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;
}

C++ if文

#include <iostream>
using namespace std;

int main()
{
int n;

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

if (n > 0)
cout << "その値は正です。\n";

return 0;
}

2018年1月20日土曜日

2018年1月19日金曜日

C++ 単項の算術演算子

#include <iostream>
using namespace std;

int main()
{
int a;

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

int b = -a;
cout << a << "の符号を反転した値は" << b << "です。\n";

return 0;
}

C++ 変数と初期化

#include <iostream>
using namespace std;

int main()
{
int x;
int y;

cout << "xの値は" << x << "です\n";
cout << "yの値は" << y << "です\n";
cout << "合計は" << x + y << "です\n";
cout << "平均は" << (x + y) / 2 << "です。\n";

return 0;
}

2018年1月6日土曜日

C# 文字型

//type08.cs

using System;

class type08
{
    public static void Main()
    {
        char a = '猫', b = 'で', c = 'も', d = 'わ', e = 'か', f = 'る';
        Console.Write(a);
        Console.Write(b);
        Console.Write(c);
        Console.Write(d);
        Console.Write(e);
        Console.Write(f);

        Console.WriteLine();
    }
}

C# decimal型

using System;


class type06
{
    public static void Main()
    {
        Console.WriteLine("decimal:{0}~{1}", decimal.MinValue,
                                             decimal.MaxValue);
    }
}

C# 浮動小数点数型

using System;

class type04
{
    public static void Main()
    {
        Console.WriteLine("float: {0}~{1}", float.MinValue,
                                            float.MaxValue);
        Console.WriteLine("double:{0}~{1}",double.MinValue,
                                            double.MaxValue);
    }
}

C# 整数型

using System;

class type02
{
    public static void Main()
    {
        Console.Write("整数を入力してください---");
        int x = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("今の数字を2倍すると{0}ですね。", x * 2);

        Console.Write("あなたの年齢を入力してください---");
        ushort age = Convert.ToUInt16(Console.ReadLine());
        Console.WriteLine("あと{0}年で100歳ですね", 100 - age);
    }
}