摘要: 典型的prim算法这类题目可以稍作变形,比如POJ2421#include <iostream>#include <map>#define MAXN 102typedef long elem_t;using namespace std;elem_t prim(int n,elem_t mat[MAXN][MAXN]){ elem_t closeEdge[MAXN],sum=0,min; int i,j,k; for(i = 0; i < n; i++) closeEdge[i] = mat[0][i];//初始化辅助数组 for(i = 1; i < n;. 阅读全文
posted @ 2011-12-21 00:34 yangleo 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 这题比较简单,就是对电话号码的字符串处理并排序输出,但是实现时有几个注意的地方1、用map存储比较方便,可以自动根据string的排序规则排序,而且题目数据恰好是<string,int>的K-V存储特点。2、用另一个字符串重新拼接待输出地字符串比直接对输入字符串进行替换移位等操作要方便。3、注意字符和数字的ASCII的转化。4、‘-’的加入可以在输出的时候,输到第4个字符的时候先输出‘-’。5、map,set,vector,deque,list等容器要熟练使用,可以参考http://www.cplusplus.com/和MSDN的文档。#include <iostream&g 阅读全文
posted @ 2011-12-21 00:31 yangleo 阅读(542) 评论(0) 推荐(0) 编辑
摘要: 这是我面试一个公司的时候碰到的面试题Q请用两个栈模拟实现队列,至少完成入队、出队及计算长度的方法A 基本思路是两次后进先出 = 先进先出,元素入队列总是入左栈,元素出队列如果右栈不为空直接弹出右栈头元素;如果右栈为空就把左栈元素出栈全部压入右栈,再弹出右栈头,这样就模拟出了一个队列。Class Q{ stack<int> S1,S2; void push(int a){ S1.push(a);} int pop(){ if(S2.empty()){ while(S1.size()>0){ S2.push(S1.pop()); } } return S2.pop();... 阅读全文
posted @ 2011-12-21 00:29 yangleo 阅读(246) 评论(0) 推荐(0) 编辑
摘要: 基本思路就是求逆序数然后根据逆序数排序,出现的问题有:1、这题出现的问题主要是对m和n总是搞混,而且提交出现了Runtime Error,这个错误一般都是由于一般都是非法访问内存(数组越界、访问空指针、堆栈溢出)、做除法时除以了0 等造成的,后来仔细看了一下“a positive integer n (0 < n <= 50) giving the length of the strings; and a positive integer m (0 < m <= 100) giving the number of strings. ”就立刻发现了错误,结构体数组开小了。 阅读全文
posted @ 2011-12-21 00:27 yangleo 阅读(309) 评论(0) 推荐(0) 编辑
摘要: TOPIC: ARGUMENT241 - The following appeared in a memo at the XYZ Company. "When XYZ lies off employees, it pays Delany Personnel Firm to offer those employees assistance in creating résumés and developing interviewing skills, if they so desire. Laid-off employees have benefited greatl 阅读全文
posted @ 2011-04-17 02:11 yangleo 阅读(123) 评论(0) 推荐(0) 编辑
摘要: TOPIC: ISSUE88 - "Technologies not only influence but actually determine social customs and ethics."WORDS: 455 TIME: 01:00:00 DATE: 2011-4-16 0:30:51The development of technologies is a main power that pushes the improvement of the society. Does technologies not only influence but actually 阅读全文
posted @ 2011-04-17 02:10 yangleo 阅读(166) 评论(0) 推荐(0) 编辑
摘要: TOPIC: ARGUMENT37 - Woven baskets characterized by a particular distinctive pattern have previously been found only in the immediate vicinity of the prehistoric village of Palean and therefore were believed to have been unique to the Palean people. Recently, however, archaeologists discovered such a 阅读全文
posted @ 2011-04-12 00:25 yangleo 阅读(525) 评论(0) 推荐(0) 编辑
摘要: TOPIC: ISSUE17 - "There are two types of laws: just and unjust. Every individual in a society has a responsibility to obey just laws and, even more importantly, to disobey and resist unjust laws."WORDS: 528 TIME: 01:00:00 DATE: 2011-4-11 23:09:15Does every individual in a society has a res 阅读全文
posted @ 2011-04-12 00:23 yangleo 阅读(193) 评论(0) 推荐(0) 编辑
摘要: TOPIC: ARGUMENT76 - The following appeared as part of an article in a health and beauty magazine."A group of volunteers participated in a study of consumer responses to the new Luxess face cream. Every morning for a month, they washed their faces with mild soap and then applied Luxess. At the e 阅读全文
posted @ 2011-04-11 00:04 yangleo 阅读(158) 评论(0) 推荐(0) 编辑
摘要: TOPIC: ISSUE144 - "It is the artist, not the critic,* who gives society something of lasting value." *a person who evaluates works of art, such as novels, films, music, paintings, etc.WORDS: 496 TIME: 01:00:00 DATE: 2011-4-10 23:13:30The speaker asserts that it is the arts rather than crit 阅读全文
posted @ 2011-04-11 00:02 yangleo 阅读(140) 评论(0) 推荐(0) 编辑