Skip to content

Commit 1ba5e0a

Browse files
committed
update
1 parent d502dc6 commit 1ba5e0a

File tree

5 files changed

+186
-0
lines changed

5 files changed

+186
-0
lines changed
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
sort(v.begin(), v.end());
2+
for (i = v.begin(); i < v.end() - 1; i++)
3+
{
4+
for (j = i + 1; j < v.end(); j++)
5+
{
6+
if (binary_search(v.begin(), v.end(), Point(j->x, i->y)) &&
7+
binary_search(v.begin(), v.end(), Point(i->x, j->y)) &&
8+
i->x != j->x &&
9+
i->y != j->y )
10+
{
11+
nTotalNum++;
12+
}
13+
}
14+
}
15+
cout << nTotalNum / 2;
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
template<class T>
2+
class CMyistream_iterator
3+
{
4+
private:
5+
T content;
6+
istream &is;
7+
public:
8+
CMyistream_iterator(istream &i):is(i)
9+
{
10+
i >> content;
11+
}
12+
T operator*()
13+
{
14+
return content;
15+
}
16+
void operator++(int)
17+
{
18+
is >> content;
19+
}
20+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#include <iostream>
2+
#include <string>
3+
using namespace std;
4+
5+
// 在此处补充你的代码
6+
template<class T>
7+
class CMyistream_iterator
8+
{
9+
private:
10+
T content;
11+
istream &is;
12+
public:
13+
CMyistream_iterator(istream &i):is(i)
14+
{
15+
i >> content;
16+
}
17+
T operator*()
18+
{
19+
return content;
20+
}
21+
void operator++(int)
22+
{
23+
is >> content;
24+
}
25+
};
26+
27+
int main()
28+
{
29+
CMyistream_iterator<int> inputInt(cin);
30+
int n1, n2, n3;
31+
n1 = *inputInt; //读入 n1
32+
int tmp = *inputInt;
33+
cout << tmp << endl;
34+
inputInt++;
35+
n2 = *inputInt; //读入 n2
36+
inputInt++;
37+
n3 = *inputInt; //读入 n3
38+
cout << n1 << "," << n2 << "," << n3 << endl;
39+
CMyistream_iterator<string> inputStr(cin);
40+
string s1, s2;
41+
s1 = *inputStr;
42+
inputStr++;
43+
s2 = *inputStr;
44+
cout << s1 << "," << s2 << endl;
45+
return 0;
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include <iostream>
2+
#include <set>
3+
#include <string>
4+
using namespace std;
5+
6+
multiset<int> int_multiset;
7+
set<int> mySet;
8+
9+
void add(int x)
10+
{
11+
int_multiset.insert(x);
12+
mySet.insert(x);
13+
cout << int_multiset.count(x) << endl;
14+
}
15+
16+
void del(int x)
17+
{
18+
int tmp = int_multiset.count(x);
19+
int_multiset.erase(x);
20+
cout << tmp << endl;
21+
}
22+
23+
void ask(int x)
24+
{
25+
set<int>::iterator i = mySet.find(x);
26+
cout << (int)(i != mySet.end()) << " " << int_multiset.count(x) << endl;
27+
}
28+
29+
int main()
30+
{
31+
int n;
32+
cin >> n;
33+
while (n--)
34+
{
35+
string op;
36+
int x;
37+
cin >> op >> x;
38+
if (op == "add")
39+
{
40+
add(x);
41+
}
42+
else if (op == "del")
43+
{
44+
del(x);
45+
}
46+
else if (op == "ask")
47+
{
48+
ask(x);
49+
}
50+
}
51+
return 0;
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#include <iostream>
2+
#include <vector>
3+
#include <algorithm>
4+
using namespace std;
5+
6+
struct Point
7+
{
8+
int x;
9+
int y;
10+
Point(int x_, int y_) :x(x_), y(y_) { }
11+
};
12+
13+
bool operator < (const Point & p1, const Point & p2)
14+
{
15+
if (p1.y < p2.y)
16+
return true;
17+
else if (p1.y == p2.y)
18+
return p1.x < p2.x;
19+
else
20+
return false;
21+
}
22+
23+
int main()
24+
{
25+
int t;
26+
int x, y;
27+
cin >> t;
28+
vector<Point> v;
29+
while (t--)
30+
{
31+
cin >> x >> y;
32+
v.push_back(Point(x, y));
33+
}
34+
vector<Point>::iterator i, j;
35+
int nTotalNum = 0;
36+
// ÔÚ´Ë´¦²¹³äÄãµÄ´úÂë
37+
sort(v.begin(), v.end());
38+
for (i = v.begin(); i < v.end() - 1; i++)
39+
{
40+
for (j = i + 1; j < v.end(); j++)
41+
{
42+
if (binary_search(v.begin(), v.end(), Point(j->x, i->y)) &&
43+
binary_search(v.begin(), v.end(), Point(i->x, j->y)) &&
44+
i->x != j->x &&
45+
i->y != j->y )
46+
{
47+
nTotalNum++;
48+
}
49+
}
50+
}
51+
cout << nTotalNum / 2;
52+
return 0;
53+
}

0 commit comments

Comments
 (0)