P99页练习3.22
#include <iostream>
#include <iterator>
#include <vector>
#include <string>
using namespace std;
int main(void)
{
/*string word;
vector <string> test;
while(cin >> word)
{
test.push_back(word);
}
//vector <string>::size_type it=test.begin();
{
for(vector<string>::iterator itr = test.begin(); itr!=test.end(); itr++)
*itr = toupper(*itr);
}*/
vector <string> ivec;
string i;
while(cin >> i )
{
ivec.push_back(i);
}
for(vector<string>::iterator it=ivec.begin(); it!=ivec.end(); it++)
{
*it=toupper(*it);
cout<< *it<< endl;
}
return 0;
}
#ifndef ex7_27_h
#define ex7_27_h
#include <iostream>
#include <string>
using namespace std;
class Screen
{
public:
typedef string::size_type pos;
Screen():cursor(0), height(0), width(0){}
Screen(pos ht, pos wd, char c)
:height(ht), width(wd), contents(ht * wd, c)
{
}
Screen(pos ht, pos wd)
:cursor(0), height(ht), width(wd),contents(ht * wd, ' ')
{
}
char get()const {return contents[cursor];}
char get(pos r, pos c)const {return contents[r*width+c];}
inline Screen& move(pos r, pos c);
inline Screen& set(char c);
inline Screen& set(pos r, pos c, char ch);
/* const Screen& display(ostream& os) const
{
do_display(os);
return *this;
}*/
const Screen& display(ostream& os) const
{
do_display(os);
return *this;
}
Screen& display(ostream& os)
{
do_display(os);
return *this;
}
/* Screen& display(ostream& os)
{
do_display(os);
return *this;
}
*/
private:
void do_display(ostream& os)const {os << contents;}
private:
pos cursor;
pos height, width;
string contents;
};
inline Screen&Screen::move(pos r, pos c)
{
cursor = r*width + c;
return *this;
}
inline Screen& Screen::set(char c)
{
contents[cursor] = c;
return *this;
}
inline Screen& Screen::set(pos r, pos c, char ch)
{
contents[r * width +c] = ch;
return *this;
}
#endif