#include <iostream> #include <algorithm> using manespace std; typedef struct{ char num[51]; int nxs=0; }dna; bool cmp(nda a,dna b){ return a.nxs < b.nxs; } int main(){ int n,m; while(scanf("%d %d",&n,&m)!=EOF){ dna d[m]; for(int i=0;i<m;i++){ scanf("%s",d[i].num); for(int j=0;j<n;j++){ for(int k=j+1;k<n;k++){ if(j>k) d[i].nxs ++; } } } sort(d,d+m,cmp); for(int j=0;j<m;j++){ printf("%s\n",d[j].num); } } return 0; } /* Main.cc:3:7: error: expected nested-name-specifier before 'manespace' using manespace std; ^ Main.cc:10:10: error: 'nda' was not declared in this scope bool cmp(nda a,dna b){ ^ Main.cc:10:20: error: expected primary-expression before 'b' bool cmp(nda a,dna b){ ^ Main.cc:10:21: error: expression list treated as compound expression in initializer [-fpermissive] bool cmp(nda a,dna b){ ^ Main.cc:10:22: error: expected ',' or ';' before '{' token bool cmp(nda a,dna b){ ^ Main.cc: In function 'int main()': Main.cc:28:19: error: 'sort' was not declared in this scope sort(d,d+m,cmp); ^ Main.cc:28:19: note: suggested alternative: In file included from /usr/include/c++/4.9/algorithm:62:0, from Main.cc:2: /usr/include/c++/4.9/bits/stl_algo.h:4705:5: note: 'std::sort' sort(_RandomAccessIterator __first, _RandomAccessIterator __last, ^ */ |
Double click to view unformatted code.