#include <iostream>
using namespace std;
#include <iomanip>
#include <string>
void a_plus_b(void);
int twice_func(int);
void ab_plusminus_add(double,double, double&, double&);
void ab_plusminus_ptr(double,double, double*, double*);
int array_sum(int[]);
int main(void)
{
int a=100, b=200;
cout << "Hello, World." << endl;
cout << "a+b=" << a+b << endl;
cout << "input a-->" ; cin >> a; cout << "a is " << a << endl;
char *str1 = "abc";
char str2[] = "123456";
string str3 = "7890";
cout << setw(20) << str1 << endl
<< setw(20) << str2 << endl;
cout << setw(20) << setfill('0') << str1 << endl;
cout << left << str1 << str2 << endl;
cout << left << str3 << endl;
cout << hex << 30 << endl;
cout << oct << 30 << endl;
cout << dec << 30 << endl;
a_plus_b();
cout << "3*2=" << twice_func(3) << endl;
int seki,shou;
ab_plusminus_add(7.3, 4.2, seki, shou);
cout << "7.3*4.2=" << seki << endl;
cout << "7.3/4.2=" << shou << endl;
ab_plusminus_ptr(3.5, 2.8, seki, shou);
cout << "3.5*2.8=" << seki << endl;
cout << "3.5/2.8=" << shou << endl;
int array[]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, sum;
sum=array_sum(array);
cout << "1から10までの合計は " << sum << endl;
return 0;
}
void a_plus_b(void)
{
int a, b;
cout << "Input a-->"; cin >> a;
cout << "Input b-->"; cin >> b;
cout << "a+b=" << a+b << endl;
}
int twice_func(int ta)
{
return(ta*2);
}
void ab_plusminus_add(double pa,double pb, double& seki, double& shou)
{
seki=pa*pb;
shou=pa/pb;
}
void ab_plusminus_ptr(double pa,double pb, double* seki, double* shou)
{
*seki=pa*pb;
*shou=pa/pb;
}
int array_sum(int array[])
{
int goukei=0;
for(int i=0; i<10; i++){
goukei+=x[i];
}
return(goukei);
}