#include
<
iostream
>
#include < string >
#include < vector >
#include < algorithm >
using namespace std;
void testString()
... {
string s="abc",t="cde";
cout << s+t << endl;
s=s+'1';
cout << s << " "<< s.size() << endl;
cin>>s>>t;
int j=s.find(t);
if (j!=-1)
cout << j << endl;
else
cout << "no found ";
cin>>s>>t;
if (s==t)
cout << "equal " ;
else if (s>t)
cout << "large " ;
else
cout << "small " ;
s="abc defg"; //getline(cin,s);
int k=s.find(" ");
if (k!=-1)
cout << s.substr(0,k) << " " << s.substr(k+1) << endl;
}
void prtVector(vector < int > v)
... {
for(int i=0; i<v.size(); i++)
cout << " "<< v[i];
cout << endl;
}
bool cmp( int a, int b)
... {
return a>b;
}
void testVector()
... {
int n;
cin>>n;
vector <int> v(n);
int i;
for(i=0; i<v.size(); i++) cin>>v[i];
sort(v.begin(),v.end());//sort,small to large
prtVector(v);
sort(v.begin(),v.end(),cmp);//sort,large to small
prtVector(v);
reverse(v.begin(),v.end());//reverse
prtVector(v);
fill(v.begin(),v.end(),0);//fill
prtVector(v);
int x=1,y=2;
swap(x,y);//swap
cout << x << " " << y << endl;
vector <vector <int> > tv;
int r,c;
cin>>r >>c;
tv.resize(r);
for(i=0;i<r;i++)
...{
tv[i].resize(c);
for(int j=0;j<tv[i].size();j++)
cin>>tv[i][j];
}
for(i=0;i<r;i++)
...{
for(int j=0;j<tv[i].size();j++)
cout << " "<< tv[i][j];
cout << endl;
}
tv.clear();
}
void run() ... {
cout << "test string ";
testString();
cout << " test vector and algorithm ";
testVector();
}
int main() ... {
run();
return 0;
}
#include < string >
#include < vector >
#include < algorithm >
using namespace std;
void testString()
... {
string s="abc",t="cde";
cout << s+t << endl;
s=s+'1';
cout << s << " "<< s.size() << endl;
cin>>s>>t;
int j=s.find(t);
if (j!=-1)
cout << j << endl;
else
cout << "no found ";
cin>>s>>t;
if (s==t)
cout << "equal " ;
else if (s>t)
cout << "large " ;
else
cout << "small " ;
s="abc defg"; //getline(cin,s);
int k=s.find(" ");
if (k!=-1)
cout << s.substr(0,k) << " " << s.substr(k+1) << endl;
}
void prtVector(vector < int > v)
... {
for(int i=0; i<v.size(); i++)
cout << " "<< v[i];
cout << endl;
}
bool cmp( int a, int b)
... {
return a>b;
}
void testVector()
... {
int n;
cin>>n;
vector <int> v(n);
int i;
for(i=0; i<v.size(); i++) cin>>v[i];
sort(v.begin(),v.end());//sort,small to large
prtVector(v);
sort(v.begin(),v.end(),cmp);//sort,large to small
prtVector(v);
reverse(v.begin(),v.end());//reverse
prtVector(v);
fill(v.begin(),v.end(),0);//fill
prtVector(v);
int x=1,y=2;
swap(x,y);//swap
cout << x << " " << y << endl;
vector <vector <int> > tv;
int r,c;
cin>>r >>c;
tv.resize(r);
for(i=0;i<r;i++)
...{
tv[i].resize(c);
for(int j=0;j<tv[i].size();j++)
cin>>tv[i][j];
}
for(i=0;i<r;i++)
...{
for(int j=0;j<tv[i].size();j++)
cout << " "<< tv[i][j];
cout << endl;
}
tv.clear();
}
void run() ... {
cout << "test string ";
testString();
cout << " test vector and algorithm ";
testVector();
}
int main() ... {
run();
return 0;
}