摘要: Divide two integers without using multiplication, division and mod operator.int divide(int dividend, int divisor) { int flag =1; if(dividend temp){ temp = temp d2){ //下面判断中的=很关键 while(d1 >= temp){ d1 = d1 - temp; result += coun... 阅读全文
posted @ 2013-03-29 11:05 冰点猎手 阅读(164) 评论(0) 推荐(0)
摘要: There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be 阅读全文
posted @ 2013-03-28 11:53 冰点猎手 阅读(182) 评论(0) 推荐(0)
摘要: 1010. Radix (25)Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is "yes", if 6 is a decimal number and 110 is a binary number.Now for any pair of positive integers N1 and N2, your task is to find the radix of one number while that of 阅读全文
posted @ 2013-03-27 00:33 冰点猎手 阅读(313) 评论(0) 推荐(0)
摘要: Product of Polynomials (25)This time, you are supposed to find A*B where A and B are two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial: K N1 aN1N2 aN2... NK aNK, where K is the number of nonz 阅读全文
posted @ 2013-03-26 21:11 冰点猎手 阅读(191) 评论(0) 推荐(0)
摘要: Maximum Subsequence SumGiven a sequence of K integers { N1, N2, ..., NK}. A continuous subsequence is defined to be { Ni, Ni+1, ..., Nj} where 1 <= i <= j <= K. TheMaximum Subsequenceis the continuous subsequence which has the largest sum of its elements. For example, given sequence { -2, 1 阅读全文
posted @ 2013-03-26 19:23 冰点猎手 阅读(183) 评论(0) 推荐(0)
摘要: 水题,没什么好说的http://pat.zju.edu.cn/contests/pat-a-practise/1006View Code 1 #include<stdio.h> 2 #include<string.h> 3 4 struct node 5 { 6 char ID[16]; 7 char in_time[10]; 8 char out_time[10]; 9 }records[200];10 int M;11 int main()12 {13 int i,min, max;14 int flag = 0; 15 while(sc... 阅读全文
posted @ 2013-03-25 13:59 冰点猎手 阅读(196) 评论(0) 推荐(0)
摘要: sprintf 函数的使用会使这道题简单很多View Code 1 #include<stdio.h> 2 #include<string.h> 3 void pt(char a) 4 { 5 switch (a) 6 { 7 case '0': printf("zero"); break; 8 case '1': printf("one"); break; 9 case '2': printf("two");break;10 case '3': 阅读全文
posted @ 2013-03-25 00:01 冰点猎手 阅读(125) 评论(0) 推荐(0)
摘要: Counting LeavesA family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.InputEach input file contains one test case. Each case starts with a line containing 0 < N < 100, the number of nodes in a tree, and M (< N), the number of 阅读全文
posted @ 2013-03-24 23:18 冰点猎手 阅读(224) 评论(0) 推荐(0)
摘要: 方法一: dijstra + DFSView Code 1 #include <stdio.h> 2 #include <string.h> 3 4 const int INF = 10000000 ; 5 int map[505][505]; 6 int dist[505]; 7 int teamNum[505]; 8 int visit[505]; 9 int N , M, C1, C2; 10 int pathNum, maxTeamNum; 11 void initApp() 12 { 13 int temp, m, n, i, j; 14 me... 阅读全文
posted @ 2013-03-24 18:24 冰点猎手 阅读(280) 评论(0) 推荐(0)
摘要: 在VertexShader 中,和顶点相关的数据如Position、Normal、Color等等均称为Attribute,为了给VertexShader传入这些数据,必须首先知道相关Attribute在Shader中位置。在layout尚未出现之间有两种设定Attribute 位置的方法。方法一OpenGL允许我们显示的设定Attribute的位置,方法二OpenGL帮我们设定好Attribute的位置,然后我们在程序中查询Attribute的位置。方法一要特别注意:设定Attribute的位置必须在Link Program 之前,如果在Link之后才设定Attribute的位置,需要重... 阅读全文
posted @ 2012-12-07 00:44 冰点猎手 阅读(469) 评论(0) 推荐(0)