Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
感谢楼主啊~In Reply To:搞不懂为什么要改成51 Posted by:springtty at 2008-10-18 20:23:07 我也是类似的方法实现,一样出错,改成51就过了,多谢楼主提醒啊 同时鄙视自己没学好C语言哈 这是我最后通过的方法: #include <iostream> #include <stdio.h> #include <vector> #include <algorithm> using namespace std; struct myStruct{ char c[51]; int flag; }; bool lower(myStruct elem1,myStruct elem2) { return elem1.flag < elem2.flag; } int main(){ vector <myStruct> v1; myStruct m1; char temp[51]; int n,m; cin>>n>>m; for(int k=0;k<m;k++){ int count=0; cin>>temp; strcpy_s(m1.c ,temp); for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ if(temp[i]>temp[j]){ count++; } } } m1.flag=count; v1.push_back(m1); } sort( v1.begin(),v1.end(),lower); for(int i=0;i<v1.size();i++) { cout<<v1[i].c<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator