/*
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
*/
/*
#include<iostream>
using namespace std;
class Circle{
int radius;
public:
Circle(int radius=1) {this->radius = radius;}
int getRadius() {return radius;}
};
template<class T>
T bigger(T a, T b)
{
if(a > b) return a;
else return b;
}
int main()
{
int a = 20, b = 50, c;
c = bigger(a,b);
cout << "20과 50 중 큰 값은" << c << endl;
Circle waffle(10), pizza(20), y;
y = bigger(waffle, pizza);
cout << "waffle과 pizza 중 큰 것의 반지름은" << y.getRadius() << endl;
}
*/
/*
#include<iostream>
#include<vector>
using namespace std;
int main()
{
vector<int> v;
int sum=0;
for(int i=0; i<10; i++)
{
int n;
cout << "정수를 입력하세요(0을 입력하면 종료)>>";
cin >> n;
if(n == 0)
{
break;
}
else
{
v.push_back(n);
for(int i=0; i<v.size(); i++)
{
cout << v[i] << " ";
sum+=v[i];
}
cout << endl;
cout << "평균 = " << sum/v.size() << endl;
}
}
}
*/
/*
#include<iostream>
#include<vector>
#include<string>
using namespace std;
class Book{
public:
string book, name;
int y;
Book(string book, string name, int y)
{
this->book = book;
this->name = name;
this->y = y;
}
string getBook()
{
return book;
}
string getName()
{
return name;
}
int getYear()
{
return y;
}
};
int main()
{
vector<Book> v;
int i;
cout << "입고할 책을 입력하세요. 년도에 -1을 입력하면 입고를 종료합니다." << endl;
for(i=0; i<10; i++)
{
string book1, name1;
int y1;
cout << "년도>>";
cin >> y1;
if(y1==-1)
{
break;
}
else
{
cout << "책이름>>";
cin >> book1;
cout << "저자>>";
cin >> name1;
Book x(book1, name1, y1);
v.push_back(x);
}
}
cout << "총 입고된 책은 " << i << "권입니다." << endl;
vector<Book>::iterator it;
string writer;
cout << "검색하고자 하는 저자의 이름을 입력하세요>>";
cin >> writer;
for(it=v.begin();it!=v.end();it++)
{
string name;
name = it->getName();
if(writer==name)
{
cout << it->getYear() << "년도, " << it->getBook() << ", " << name << endl;
}
}
int year;
cout << "검색하고자 하는 년도를 입력하세요>>";
cin >> year;
for(it=v.begin();it!=v.end();it++)
{
int y;
y = it->getYear();
if(y == year)
{
cout << year << "년도, " << it->getBook() << ", " << it->getName() << endl;
}
}
}
*/
/*
#include<iostream>
#include<map>
#include<string>
using namespace std;
int main()
{
map<string, int> dic;
cout << "***점수관리 프로그램 HIGH SCORE을 시작합니다***" << endl;
while(true)
{
int n,s;
string name;
cout << "입력:1, 조회:2, 종료:3 >>";
cin >> n;
if(n==1)
{
cout << "이름과 점수>> ";
cin >> name >> s;
dic.insert(make_pair(name,s));
}
else if(n==2)
{
cout << "이름>> ";
cin >> name;
cout << name << "의 점수는 " << dic[name] << endl;
}
else
{
cout << "프로그램을 종료합니다..." << endl;
break;
}
}
}
*/
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main()
{
map<string, string> dic;
cout << "***암호관리 프로그램 WHO를 시작합니다***" << endl;
int n;
while(true)
{
string name, pw;
cout << "삽입:1, 검사:2, 종료:3>>";
cin >> n;
if(n==1)
{
cout << "이름 암호>>";
cin >> name >> pw;
dic.insert(make_pair(name,pw));
}
else if(n==2)
{
cout << "이름?";
cin >> name;
if(dic.find(name)==dic.end())
{
cout<< "실패~~" << endl;
}
else
{
cout << "암호?";
cin >> pw;
if(dic[name] == pw)
{
cout << "통과!!" << endl;
}
else
{
cout << "실패~~" << endl;
}
}
}
else
{
cout << "종료합니다..." << endl;
}
}
}