桑海

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2012年12月8日

摘要: #include<iostream>using namespace std;const int maxn = 5000;int main(){ void insertion_sort(int A[], int n); void put(int A[], int n); int n, A[maxn]; cin >> n; for(int i = 0; i < n; ++i) cin >> A[i]; insertion_sort(A, n); put(A, n); return 0;}void insertion_sort(int A... 阅读全文
posted @ 2012-12-08 22:41 桑海 阅读(134) 评论(0) 推荐(0) 编辑

摘要: #include<iostream>using namespace std;const int maxn = 5000;int main(){ void selection_sort(int A[], int n); void put(int A[], int n); int n, A[maxn]; cin >> n; for(int i = 0; i < n; ++i) cin >> A[i]; selection_sort(A, n); put(A, n); return 0;}int min(int A[], int beg, int... 阅读全文
posted @ 2012-12-08 22:38 桑海 阅读(141) 评论(0) 推荐(0) 编辑

摘要: #include<iostream>using namespace std;const int maxn = 5000;int main(){ void merge_sort(int a[], int beg, int end); void put(int a[], int n); int a[maxn], n; cout << "Enter a number: "; cin >> n; cout << "Enter some numbers:" << endl; for(int i = 0; 阅读全文
posted @ 2012-12-08 22:30 桑海 阅读(184) 评论(0) 推荐(0) 编辑

2012年11月17日

摘要: 抠佽了一天就弄了这个:还不错总算是弄出来了。希望有建议和补充:我的CSDN博客链接:桑海的CSDN博客 1 #include<iostream> 2 #include<sstream> //stringstream 3 #include<cstdio> //sscanf,sprintf() 4 using namespace std; 5 6 int main() 7 { 8 //*************************************************block1*********************************** 阅读全文
posted @ 2012-11-17 23:46 桑海 阅读(5046) 评论(0) 推荐(1) 编辑

2012年11月15日

摘要: A particle has initial velocity and constant acceleration. If its velocity after certain time is v then what will its displacement be in twice of that time? Input The input will contain two integers i... 阅读全文
posted @ 2012-11-15 22:38 桑海 阅读(110) 评论(0) 推荐(0) 编辑

摘要: Write a complete program that will correctly decode a set of characters into a valid message. Your program should read a given file of a simple coded set of characters and print the exact message that... 阅读全文
posted @ 2012-11-15 22:36 桑海 阅读(186) 评论(0) 推荐(0) 编辑

摘要: he just calculates one thing, the difference between his soldier number and the opponent's soldier number. From this difference he decides whether to fight or not. Hashmat's soldier number is never greater than his opponent.InputThe input contains two integer numbers in every line. These two 阅读全文
posted @ 2012-11-15 22:27 桑海 阅读(160) 评论(0) 推荐(0) 编辑

摘要: 明明题目上写着不要输出多余的空白行,可是最后还是需要一个空白行的,白白让我郁闷了多次WA: #include<iostream>using namespace std;int main(){ int i_case; cin >> i_case; while(i_case--) { int farmer; cin >> farmer; ... 阅读全文
posted @ 2012-11-15 22:21 桑海 阅读(224) 评论(0) 推荐(0) 编辑

摘要: 这道题本来是想自己写一个判断是否是英文字符的函数的,错误了,现在还不是很明白,如下: #include<iostream>#include<string>#include<cctype>using namespace std;int main(){ string line; while(getline(cin, line)) { int cnt = 0, flag ... 阅读全文
posted @ 2012-11-15 21:50 桑海 阅读(202) 评论(0) 推荐(0) 编辑

摘要: 转载:自判断点是否在三角形内部 给定三角形ABC和一点P(x,y,z),判断点P是否在ABC内。这是游戏设计中一个常见的问题。需要注意的是,这里假定点和三角形位于同一个平面内。 内角和法 连接点P和三角形的三个顶点得到三条线段PA,PB和PC,求出这三条线段与三角形各边的夹角,如果所有夹角之和为360度,那么点P在三角形内,否则不在,此法直观,但效率低下。 同向法 假设点P位于三角形内,会有这样... 阅读全文
posted @ 2012-11-15 14:51 桑海 阅读(1187) 评论(0) 推荐(0) 编辑