#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <string>
#include <ctime>
#include <algorithm>
using namespace std;
/*
//313p NO.01-1
int add(int x[], int size) {
int s = 0;
for(int i=0; i<size; i++)
s += x[i];
return s;
}
int add(int x[], int size, int y[]) {
return add(x, size) + add(y, size);
}
int main(){
int a[]={1, 2, 3, 4, 5};
int b[]={6, 7, 8, 9, 10};
int c = add(a,5);
int d = add(a, 5, b);
cout<< c<< endl;
cout<<d<< endl;
}
*/
/*
//313p NO.02
class Person{
int id;
double weight;
string name;
public:
Person();
Person(int id, string name);
Person(int id, string name, double weight);
void show(){cout<<id<<' '<<weight<<' ' <<name<< endl;}
};
Person::Person(){
this->id=1;
this->name= "Grace";
this->weight=20.5;
}
Person::Person(int id, string name){
this->id=2;
this->name="Ashley";
this->weight=20.5;
}
Person::Person(int id, string name, double weight){
this->id=3;
this->name="Helen";
this->weight=32.5;
}
int main() {
Person grace, ashley(2, "Ashley"), helen(3, "Helen", 32.5);
grace.show();
ashley.show();
helen.show();
}
*/
/*
//314p NO.03-1
int big(int a, int b){
int max =100;
int x;
x=(a>b)?a:b;
return (x<max)? x:max;
}
int big(int a, int b, int max){
int x;
x=(a>b)?a:b;
return (x<max)?x:max;
}
int main() {
int x = big(3, 5);
int y = big(300, 60);
int z = big(30, 60, 50);
cout << x << ' ' << y << ' ' << z << endl;
}
*/
/*
//314p NO.04
class MyVector {
int *mem;
int size;
public:
MyVector(int n, int val);
~MyVector() { delete[]mem; }
};
MyVector::MyVector(int n = 100, int val = 0) {
mem = new int[n];
size = n;
for (int i = 0; i < size; ++i) mem[i] = val;
for (int i = 0; i < size; ++i) cout << mem[i] << ' ';
cout << endl;
cout << "size= " << size << endl;
}
int main() {
MyVector a;
MyVector b(5, 10);
}
*/
/*
//315p NO.05
class ArrayUtility{
public:
static void intToDouble(int source[], double dest[], int size);
static void doubleToInt(double source[], int dest[], int size);
};
void ArrayUtility:: intToDouble(int source[], double dest[], int size){
for(int i=0; i<size; i++)
dest[i] =(double)source[i];
}
void ArrayUtility::doubleToInt(double source[], int dest[], int size){
for(int i=0; i<size; i++)
dest[i] = (int)source[i];
}
int main() {
int x[] = {1,2,3,4,5};
double y[5];
double z[] = {9.9, 8.8, 7.7, 6.6, 5.6};
ArrayUtility::intToDouble(x, y, 5);
for(int i=0; i<5; i++) cout << y[i] << ' ';
cout << endl;
ArrayUtility::doubleToInt(z, x, 5);
for(int i=0; i<5; i++) cout << x[i] << ' ';
cout<< endl;
}
*/
/*
//316p NO.06 모르겠디
class ArrayUtility2{
public:
static int* concat(int s1[], int s2[], int size);
static int* remove(int s1[], int s2[], int size, int& retSize);
};
int* ArrayUtility2::concat(int s1[], int s2[], int size){
int *a new int[size*2];
for(int i=0; i<size; ++i)
a[i]=s1[i];
for(int i=0;i<size; ++i)
a[1+size]=s2[i];
return a;
}
int* ArrayUtility2::remove(int s1[], int s2[], int size, int& retSize){
}
int main(){
int x[5], y[5], *z;
int retSize;
cout << "정수를 5개 입력하라. 배열 x에 삽입한다>>";
for (int i = 0; i < 5; ++i)
cin >> x[i];
cout << "정수를 5개 입력하라. 배열 y에 삽입한다>>";
for (int i = 0; i < 5; ++i)
cin >> y[i];
z=ArrayUtility2::concat(x,y,5);
cout<< "합친 정수 배열을 출력한다"<<endl;
cout << z[i] << ' ';
cout<< endl;
z=ArrayUtility2::remove(x,y,5,retSize);
cout<< "배열 x[]에서 y를 뺀 결과를 출력한다. 개수는 2"<<endl;
for(int i=0; i<retSize; ++i)
cout<<z[i]<< ' ';
cout << endl;
}
*/
/*
//316p NO.07
class Random{
public:
static void seed(){ srand((unsigned)time(0)); }
static int nextInt(int min=0, int max=32767);
static char nextAlphabet();
static double nextDouble();
};
int Random::nextInt(int min, int max){
int r= rand() % (max-min+1)+min;
return r;
}
char Random::nextAlphabet(){
char c= rand() %2;
if(c==0){
c=(rand()%26)+65;
return c;
}
else{
c=(rand()%26)+97;
return c;
}
}
double Random::nextDouble(){
double d= rand()/ (double)(RAND_MAX+1);// 0부터 32767의 정수를 32768로 나누면 실수가 나온다
return d;
}
int main(){
Random::seed();
cout<<"1에서 100까지 랜덤한 정수 10개를 출력합니다."<<endl;
for (int i = 0; i < 10; ++i) {
cout << Random::nextInt(1, 100) << ' ';
}
cout<<endl;
cout<<"알파벳을 랜덤하게 10개를 출력합니다."<<endl;
for (int i = 0; i < 10; ++i) {
cout << Random::nextAlphabet() << ' ';
}
cout<<endl;
cout<< "랜덤한 실수를 10개 출력합니다."<<endl;
for (int i = 0; i < 5; ++i) {
cout << Random::nextDouble() << ' ';
}
cout << endl;
for (int i = 0; i < 5; ++i) {
cout << Random::nextDouble() << ' ';
}
cout << endl;
}
*/