31

 1 #include <iostream>
 2 #include <string>
 3 
 4 using namespace std;
 5 template <class T>
 6 class CMyistream_iterator
 7 {
 8 private:
 9     istream& in;
10     T value;
11 public:
12     CMyistream_iterator(istream& _in):in(_in){
13         cin >> value;
14     }
15     T operator*(){
16         return value;
17     }
18     void operator++(int){
19         in >> value;
20     }
21 };
22 
23 
24 
25 int main()  
26 { 
27     int t;
28     cin >> t;
29     while( t -- ) {
30          CMyistream_iterator<int> inputInt(cin);
31          int n1,n2,n3;
32          n1 = * inputInt; //读入 n1
33          int tmp = * inputInt;
34          cout << tmp << endl;
35          inputInt ++;   
36          n2 = * inputInt; //读入 n2
37          inputInt ++;
38          n3 = * inputInt; //读入 n3
39          cout << n1 << " " << n2<< " " << n3 << " ";
40          CMyistream_iterator<string> inputStr(cin);
41          string s1,s2;
42          s1 = * inputStr;
43          inputStr ++;
44          s2 = * inputStr;
45          cout << s1 << " " << s2 << endl;
46     }
47      return 0;  
48 }

 

 1 #include <iostream>
 2 #include <string>
 3 
 4 using namespace std;
 5 template <class T>
 6 class CMyistream_iterator
 7 {
 8 private:
 9     istream& in;
10     T value;
11 public:
12     CMyistream_iterator(istream& _in):in(_in){
13         cin >> value;
14     }
15     T operator*(){
16         return value;
17     }
18     CMyistream_iterator operator++(int){
19         in >> value;
20         return *this;
21     }
22 };
23 
24 
25 
26 int main()  
27 { 
28     int t;
29     cin >> t;
30     while( t -- ) {
31          CMyistream_iterator<int> inputInt(cin);
32          int n1,n2,n3;
33          n1 = * inputInt; //读入 n1
34          int tmp = * inputInt;
35          cout << tmp << endl;
36          inputInt ++;   
37          n2 = * inputInt; //读入 n2
38          inputInt ++;
39          n3 = * inputInt; //读入 n3
40          cout << n1 << " " << n2<< " " << n3 << " ";
41          CMyistream_iterator<string> inputStr(cin);
42          string s1,s2;
43          s1 = * inputStr;
44          inputStr ++;
45          s2 = * inputStr;
46          cout << s1 << " " << s2 << endl;
47     }
48      return 0;  
49 }

 

posted @ 2022-09-13 22:54  balabalahhh  阅读(184)  评论(0编辑  收藏  举报