Chap5: question: 29 - 31】的更多相关文章

29. 数组中出现次数超过一半的数字. 方法a. 排序取中       O(nlogn). 方法b. partition 函数分割找中位数     >=O(n). 方法c. 设计数变量,扫描一遍.     O(n). #include <stdio.h> int getNumber(int data[], int length){ /* if(checkInvalidArray(data, length)) return 0; */ int count = 1, value = data…
35. 第一个只出现一次的字符 char firtNotRepeat(char *s) { if(s == NULL) return 0; int i = 0; while(s[i] != '\0') record[s[i++]] ^= 1; i = 0; while(!record[s[i]]) ++i; return s[i]; } 36.数组中的逆序对个数 (归并排序解法) #include <iostream> using namespace std; void inversePair…
Question 习题3-1 得分(Score ACM-ICPC Seoul 2005,UVa1585) 题目:给出一个由O和X组成的串(长度为1~80),统计得分. 每个O的分数为目前连续出现的O的个数,X的得分为0. 例如:OOXXOXXOOO的得分为1+2+0+0+1+0+0+1+2+3. DescriptionThere is an objective test result such as OOXXOXXOOO. An `O' means a correct answer of a p…
Question 29. Divide Two Integers Solution 题目大意:给定两个数字,求出它们的商,要求不能使用乘法.除法以及求余操作. 思路:说下用移位实现的方法 7/3=2,7是被除数,3是除数 除数左移,假设移动了n次后,移到最接近被除数,这时被除数=被除数-除数,商的一部分为2^n 如果被除数>除数,则继续循环 除数左移,又移动了m次后,移到最接近被除数,这时被除数=被除数-除数,商的一部分为2^m 最后商为2^n+2^m+... Java实现: 法1:如果可以用除…
二,RoundC import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.PrintStream; import java.util.ArrayList; import java.util.…
QUESTION 13 View the Exhibit.Examine the following command that is executed for the TRANSPORT table in the SH schema:SQL> SELECT DBMS_STATS.CREATE_EXTENDED_STATS('sh', 'customers_obe', '(country_id,cust_state_province)') FROM dual;Which statement des…
Question 29 You are designing a SharePoint 2010 intranet site at your company. The accounting department has designed a  SharePoint list. They need this list to be included in any new site that is created by using the Team Site site definition provid…
Question28You have a Microsoft Office SharePoint Server 2007 site.You upgrade the site to SharePoint Server 2010.You need to create a Feature that prevents site collection administrators from upgrading the user interface of the site to SharePoint Ser…
Problem Description Eddy's interest is very extensive, recently he is interested in prime number. Eddy discover the all number owned can be divided into the multiply of prime number, but he can't write program, so Eddy has to ask intelligent you to h…
Calendar Game Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2071 Accepted Submission(s): 1185 Problem Description Adam and Eve enter this year’s ACM International Collegiate Programming Contest.…