随笔分类 -  搜索以及排序

uva 10785 - The Mad Numerologist
摘要:这题就是计算元音和辅音的个数,放到两个容器里,再按字典序排序一开始漏写了个辅音,错了一次 1 #include 2 #include 3 #include 4 using namespace std; 5 int main(){ 6 int n; 7 cin>>n; 8 vector v_vowel; 9 vector v_consonants;10 char vowel[5]={'A','U','E','O','I'};11 char consonants[21]={'J',' 阅读全文

posted @ 2014-01-02 20:57 云在心 阅读(137) 评论(0) 推荐(0)

uva 755 - 487--3279
摘要:算法是蛮简单的,不过超时了 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 vector v_number; 9 vector v_num;10 int main(){11 int n;12 cin>>n;13 string l;14 getchar();15 char CmapN[100];16 CmapN['A']=CmapN['B']=CmapN['C']='2';17 CmapN 阅读全文

posted @ 2014-01-02 19:32 云在心 阅读(290) 评论(0) 推荐(0)

uva 10194 - Football (aka Soccer)
摘要:又是wa,有点搞不懂 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 typedef struct infoteam{ 9 string name; 10 int games; 11 int point; 12 int win; 13 int tie; 14 int lose; 15 int difference; 16 int score; 17 int against;... 阅读全文

posted @ 2013-12-31 10:42 云在心 阅读(196) 评论(0) 推荐(0)

uva 123 - Searching Quickly
摘要:这题是wa,现在没时间改,应该是单词搜寻那里有问题,搜th,the也能搜到 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 typedef struct combine{ 8 string word; 9 int i;10 string replaceword;11 bool operator dictionnary;23 int main(){24 vector igwords;25 vector sentence;26 s... 阅读全文

posted @ 2013-12-30 19:24 云在心 阅读(127) 评论(0) 推荐(0)

uva 400 - Unix ls
摘要:这题其实很简单,但是re了很多次,因为天真到用setw,以及cout 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 int main(){10 int n;11 vector words;12 while(cin>>n){13 getchar();14 string l;15 int max=0;16 for(int i=0;i0)?(n/columnnum+1):(n/c... 阅读全文

posted @ 2013-12-26 21:48 云在心 阅读(166) 评论(0) 推荐(0)

uva 156 - Ananagrams
摘要:思路:1.先读取单词,把单词都整齐一下,从大写变为小写2.把单词按字母进行排序3.判断接下来的单词和前面的单词是否重复 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 vector newwords; 8 vector num; 9 vector oldwords;10 int main(){11 string l;12 vector::iterator it;13 while(getline(cin,l)){14 if(l[0]=='#... 阅读全文

posted @ 2013-12-26 20:12 云在心 阅读(191) 评论(0) 推荐(0)

uva 120 - Stacks of Flapjacks (RE)
摘要:一直runtime error,这题要注意,有可能数字是重复的。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 vector q_numb; 8 int len; 9 void q_sort(vector &numb){10 int max=0,pos=0,i=0;11 for(vector::iterator it=numb.begin();it!=numb.end();it++,i++){12 if(max(temp.c_str())));43... 阅读全文

posted @ 2013-12-26 14:41 云在心 阅读(142) 评论(0) 推荐(0)

uva 299 - Train Swapping
摘要:水题。。。 1 #include 2 using namespace std; 3 int main(){ 4 int n; 5 int num[51]; 6 cin>>n; 7 while(n--){ 8 int l,cishu=0; 9 cin>>l;10 for(int i=0;i>num[i];12 for(int i=0;inum[j]){15 int temp=num[i];16 num[i]=num[j];... 阅读全文

posted @ 2013-12-25 20:37 云在心 阅读(190) 评论(0) 推荐(0)

uva 152 Tree's a Crowd
摘要:突然不能登了,玩了局dota,编了这题,这题还是比较简单,英语拙计啊 1 #include 2 #include 3 #include 4 using namespace std; 5 int x[5010],y[5010],z[5010]; 6 int main(){ 7 int num=0,a[10]; 8 for(int i=0;i>x[num]>>y[num]>>z[num]){11 if(!x[num]&&!y[num]&&!z[num])12 break;13 num++;14 }15 for(... 阅读全文

posted @ 2013-12-25 17:04 云在心 阅读(116) 评论(0) 推荐(0)

uva 10474 Where is the Marble?
摘要:排序而已。。。。不过时间有点长,以后再考虑考虑怎么写 1 #include 2 #include 3 #include 4 using namespace std; 5 vector num; 6 int main(){ 7 int n,q,cishu=1; 8 vector::iterator result; 9 while(cin>>n>>q){10 if(!n&&!q)11 break;12 int temp;13 for(int i=0;i>temp;15 num.p... 阅读全文

posted @ 2013-12-25 14:12 云在心 阅读(134) 评论(0) 推荐(0)

uva 10420 - List of Conquests
摘要:这题写的好丑啊,这题感觉就是烦1.先要把单词读到一个数组,并记录次数2.对单词进行排序虽然只有0.022s,感觉写的太丑了不过这题温习了一下vector的用法,还有qsort的用法 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define MIN(a,b) ((a)>(b))?(b):(a) 9 using namespace std;10 vector v_word;11 vector v_num;12 typedef struct Node{13 string s;.. 阅读全文

posted @ 2013-12-25 13:44 云在心 阅读(186) 评论(0) 推荐(0)

uva 340 Master-Mind Hints
摘要:这题就是判断,先判断正确的,再判断位置不对但是数字对的这题开始提交都是 runtime error因为数组开的太小了,以后开大点。 1 #include 2 using namespace std; 3 int same,diff; 4 void juge(int len,int a[],int b[]){ 5 int tempa[1000],tempb[1000]; 6 same=0,diff=0; 7 for(int i=0;i>n){31 if(n==0)32 break;33 for(int i=0;i>a... 阅读全文

posted @ 2013-12-23 20:43 云在心 阅读(283) 评论(2) 推荐(0)

导航