Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
27962 唐心 长方形排序 C++ Accepted 47 MS 760 KB 1186 2022-06-12 18:47:48

Tests(10/10):


Code:

#include<iostream> #include<cmath> #include<cstdio> #include<cstring> using namespace std; typedef struct cfx { int No; int chang; int kuan; }cfx_s; bool cfx_sort(cfx_s s1,cfx_s s2) { if(s1.No > s2.No) return true; else if(s1.No == s2.No) { if(s1.chang > s2.chang) return true; else if(s1.chang == s2.chang) { if(s1.kuan > s2.kuan) return true; } } return false; } int main() { int i,j,m,temp_c,temp_k; cfx_s arr[1001] = {0},temp; cin >> m; for(i = 0; i < m; i++) { cin >> arr[i].No; cin >> temp_c; cin >> temp_k; if(temp_c < temp_k) { arr[i].chang = temp_k; arr[i].kuan = temp_c; } else { arr[i].chang = temp_c; arr[i].kuan = temp_k; } } for(i = 0; i < m-1; i++) { for(j = 0; j < m-i-1; j++) { if(cfx_sort(arr[j],arr[j+1])) { temp = arr[j]; arr[j] = arr[j+1]; arr[j+1] = temp; } } } for(i = 0; i < m; i++) { if(arr[i].No == arr[i+1].No && arr[i].chang == arr[i+1].chang && arr[i].kuan == arr[i+1].kuan) continue; cout << arr[i].No <<" "<<arr[i].chang<<" "<<arr[i].kuan<<endl; } return 0; }