#include <stdio.h>
struct Employee {
int Number; // 社員番号
char *Name; // 名前
int Salary; // 給料
int Years; // 勤続年数
};
void main(void)
{
struct Employee emp[2];
emp[0].Number = 1;
emp[0].Name = "山田太郎";
emp[0].Salary = 50;
emp[0].Years = 5;
emp[1].Number = 2;
emp[1].Name = "田中二郎";
emp[1].Salary = 10;
emp[1].Years = 1;
for (int i = 0; i < 2; i++)
{
printf("社員番号:%d, 名前:%s, 給料:%d円, 勤続年数:%d年\n", emp[i].Number, emp[i].Name, emp[i].Salary, emp[i].Years);
}
}
#include <iostream>
#include <string>
using namespace std;
struct Employee {
int Number; // 社員番号
string Name; // 名前
int Salary; // 給料
int Years; // 勤続年数
void SalaryIncrease()
{
Salary *= 1.5;
};
};
int main()
{
Employee emp[2];
emp[0].Number = 1;
emp[0].Name = "山田太郎";
emp[0].Salary = 50;
emp[0].Years = 5;
emp[1].Number = 2;
emp[1].Name = "田中二郎";
emp[1].Salary = 10;
emp[1].Years = 1;
for (int i = 0; i < 2; i++)
{
cout << "社員番号:" << emp[i].Number << ", 名前:" << emp[i].Name << ", 給料:" << emp[i].Salary << "円, 勤続年数:" << emp[i].Years << endl;
}
cout << "昇給!!" << endl;
emp[0].SalaryIncrease();
emp[1].SalaryIncrease();
for (int i = 0; i < 2; i++)
{
cout << "社員番号:" << emp[i].Number << ", 名前:" << emp[i].Name << ", 給料:" << emp[i].Salary << "円, 勤続年数:" << emp[i].Years << endl;
}
return 0;
}
#include <iostream>
using namespace std;
class Calc {
int Num1;
int Num2;
int Add()
{
return Num1 + Num2;
}
};
int main()
{
Calc calc;
calc.Num1 = 10;
calc.Num2 = 20;
cout << calc.Add() << endl;
return 0;
}
#include <iostream>
using namespace std;
struct Calc {
int Num1;
int Num2;
int Add()
{
return Num1 + Num2;
}
};
int main()
{
Calc calc;
calc.Num1 = 10;
calc.Num2 = 20;
cout << calc.Add() << endl;
return 0;
}