本蒟蒻又来求助了!
查看原帖
本蒟蒻又来求助了!
317198
MilkyCoffee楼主2020/5/8 16:42

哈喽大家好,我又是那个牛奶小咖啡

我的开场白依旧:尽管我的代码里有注释,但是依然可读性极差...

这一次有一点不同,这次我本来是可以挑出错的,但是我平常用的本地编译器坏了,新下的编译器又不会用,希望dalao们如果挑出数组越界、变量名打错之类的错误请多多包涵...

1、2点WA,60分代码:

// #include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
using namespace std;

int n; // n
string a[25]; // 票数
int b[25]; // 人们的编号

int main() {
	cin >> n; // 输入
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i] = i;
	}
	for (int j = n; j > 1; j--) {
		for (int i = 1; i < j; i++) {
			if (a[i] > a[i+1]) {
				swap(a[i], a[i+1]); // 交换
				swap(b[i], b[i+1]); // 同上
			}
		}
	}
	cout << b[n] << endl; // 输出
	cout << a[n] << endl;
	return 0;
}

2020/5/8 16:42
加载中...