0%

Socket(套接字)

套接字是计算机进程与网络之间的一个接口,准确地说,是应用层与运输层之间的接口,因此套接字也成为应用程序与网络之间的API。一个套接字是连接的一个端点,客户端与服务器端通过套接字传输数据。每个套接字由一个IP地址和端口号决定,表示为“地址:端口”。

Read more »

Google浏览器缓存真的是个大坑,当在后台更新了网页的内容,但打开网页一看还跟原来一毛一样,这种无妄之灾会对人的心理造成很大的伤害。下面是几种解决方法:

Read more »

由于是初次尝试面向对象的编程,觉得之前搭建的结构有诸多不妥之处。因此进行一次整理优化。

除非程序员做功,否则代码总是朝着熵增的方向进行——热力学第四定律

Read more »

上一篇文章中,我在Qt中搭建了一个Opengl绘制框架,并绘制了一个三角形,为了让朴实无华且枯燥的三角形动起来,我决定创建一个摄像机。

Read more »

每次建立新的OpenGL工程,都要翻翻笔记,做一些复制粘贴的工作,非常朴实无华且枯燥。于是我便产生了搭建一个比较通用的OpenGL模板的想法。最近又在学习Qt和设计模式,顺便将OpenGL与Qt相结合,并亲手实践一些设计模式,权当练手罢。

Read more »

题意

输入格式

Each input file contains one test case. For each case, the first line contains 2 positive integers N (2≤N≤200), the number of cities, and K, the total number of routes between pairs of cities; followed by the name of the starting city. The next N−1 lines each gives the name of a city and an integer that represents the happiness one can gain from that city, except the starting city. Then K lines follow, each describes a route between two cities in the format City1 City2 Cost. Here the name of a city is a string of 3 capital English letters, and the destination is always ROM which represents Rome.

Read more »

题目:

Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output Fu first if it is negative. For example, -123456789 is read as Fu yi Yi er Qian san Bai si Shi wu Wan liu Qian qi Bai ba Shi jiu. Note: zero (ling) must be handled correctly according to the Chinese tradition. For example, 100800 is yi Shi Wan ling ba Bai.

Read more »

题目大意

given L being 1→2→3→4→5→6, if K=3, then you must output 3→2→1→6→5→4; if K=4, you must output 4→3→2→1→5→6.

解题关键

用哈希表存储链表,在链表头需要另外插入一个空节点指向原链表头。
反转的迭代中需要三个临时指针,分别指向被反转节点及其之前、之后的位置。注意逆转节点段头尾的处理。注意链表尾边界情况的处理。

Read more »

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <sstream>
using namespace std;
//核心,判断哪个数字段排前面的算法
//局部规划+贪婪?,本质上就是先乱序建立好一个数字段,
//交换两个数字段,如果交换后有提升,则采纳;如果无提升,就不采纳
bool cmp(const string& lhs, const string& rhs) {
string temp1 = lhs + rhs;
string temp2 = rhs + lhs;
if (temp1 < temp2) return 1;
else if (temp1 == temp2 && temp1.size() < temp2.size()) return 1;
else return 0;
}
int main() {
int n;
cin >> n;
vector<string> nums;
for (int i=0; i < n; i++) {
string temp;
cin >> temp;
nums.push_back(temp);
}
sort(nums.begin(), nums.end(),cmp);
string result;
for (int i = 0; i < nums.size(); i++) {
result += nums[i];
}
//输入参数全0的情况
int off = result.find_first_not_of('0');
if (off == -1) cout << 0;
else cout << result.substr(off);
}