目录
晚风依旧很温柔
——《银河与星斗》
害死人不偿命的(3n+1)猜想
#include<iostream>
using namespace std;
int main()
{
int n, i=0;
cin >> n;
while (n != 1) {
if (n % 2 == 0) {
n /= 2;
i++;
}
else {
n = (3 * n + 1) / 2;
i++;
}
}
cout << i << endl;
return 0;
}
永远太漫长了,看不到未来
——《夜行》
成绩排名
#include<iostream>
#include<string>
using namespace std;
struct Student {
string name;
string id;
int score;
};
int main()
{
int n;
cin >> n;
Student stu[10001];
//录入成绩
for (int i = 0; i < n; i++) {
cin >> stu[i].name >> stu[i].id >> stu[i].score;
}
//成绩排序
int max = stu[0].score;
int min = stu[0].score;
for (int i = 1; i < n; i++) {
if (max < stu[i].score) {
max = stu[i].score;
}
else if (min > stu[i].score) {
min = stu[i].score;
}
}
//输出结果
for (int i = 0; i < n; i++) {
if (max == stu[i].score) {
cout << stu[i].name << " " <<stu[i].id << endl;
}
}
for (int i = 0; i < n; i++) {
if (min == stu[i].score) {
cout << stu[i].name << " " << stu[i].id << endl;
}
}
return 0;
}
偏爱和例外.