#include <iostream>
using namespace std;
int main()
{
int n;
cout << “整数値:”;
cin >> n;
if (n > 0)
cout << “その値は正です。n”;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int n;
cout << “整数値:”;
cin >> n;
if (n > 0)
cout << “その値は正です。n”;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int a;
cout << “整数値:”;
cin >> a;
int b = -a;
cout << a << “の符号を反転した値は” << b << “です。n”;
return 0;
}
#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;
}
//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();
}
}
using System;
class type06
{
public static void Main()
{
Console.WriteLine(“decimal:{0}~{1}”, decimal.MinValue,
decimal.MaxValue);
}
}
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);
}
}
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);
}
}
http://wisdom.sakura.ne.jp/programming/cpp/cpp27.html
#include <iostream>
using namespace std;
class Array {
int ary[2];
public:
int & operator [](int n) { return ary[n]; }
} obj;
int main() {
obj[0] = 10;
obj[1] = 100;
cout << “obj[0] = ” << obj[0] << ‘n’;
cout << “obj[1] = ” << obj[1] << ‘n’;
return 0;
}
using static System.Console;
class Welcome
{
/// <summary>
/// saying hello to all visitors and welcome.
/// </summary>
/// <param name="args">visitors</param>
public static void Main(string[] args)
{
foreach(string visitor in args)
{
WriteLine($"Hello {visitor}.");
}
WriteLine("Welcome to my web page.");
}
}
http://ufcpp.net/
#include <iostream>
using namespace std;
int main()
{
cout <<“hello” << endl;
cout << “hello ” << endl;
}