11 2012 档案
摘要:抠佽了一天就弄了这个:还不错总算是弄出来了。希望有建议和补充:我的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***********************************
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要: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
阅读全文
摘要:明明题目上写着不要输出多余的空白行,可是最后还是需要一个空白行的,白白让我郁闷了多次WA: #include<iostream>using namespace std;int main(){ int i_case; cin >> i_case; while(i_case--) { int farmer; cin >> farmer; ...
阅读全文
摘要:这道题本来是想自己写一个判断是否是英文字符的函数的,错误了,现在还不是很明白,如下: #include<iostream>#include<string>#include<cctype>using namespace std;int main(){ string line; while(getline(cin, line)) { int cnt = 0, flag ...
阅读全文
摘要:转载:自判断点是否在三角形内部 给定三角形ABC和一点P(x,y,z),判断点P是否在ABC内。这是游戏设计中一个常见的问题。需要注意的是,这里假定点和三角形位于同一个平面内。 内角和法 连接点P和三角形的三个顶点得到三条线段PA,PB和PC,求出这三条线段与三角形各边的夹角,如果所有夹角之和为360度,那么点P在三角形内,否则不在,此法直观,但效率低下。 同向法 假设点P位于三角形内,会有这样...
阅读全文
摘要:刚开始想直接求出n的阶乘,在从其结果里面查找相应的素数,可是发现数字太大,越界了,经改正如下: My Code: #include<iostream>using namespace std;int prime[100];void prime_array() //生成素数表{ for(int i = 2, k = 0; i < 100; ++i) { int...
阅读全文
摘要:题目分析: 本题是由对角线由1起,每次递增以,交替循环。 1 2 6 7 15 16 3 5 8 14 17 4 9 13 18 10 12 19 11 20 21 如上表:红黑交替,每次递增1. 以以每条对角线为整体,前k条对角线一共有:1+2+3+4+5+6+7+8+9+……+k+……(k表示第k条对角线)个数。 现在要确定输入数n的所行与列...
阅读全文
摘要://---------------MY CODE-------------------------#include<iostream>#include<vector>#include<string>using namespace std;string get(string word){ for(int i = 1; i != word.size(); ++i) { ch...
阅读全文
摘要:1 //--------------------C_Style---------------------- 2 3 #include<stdio.h> 4 #include<string.h> 5 const int maxn = 3000; 6 7 int get_next(int n) 8 { 9 char str[10];10 sprintf(str, "%d", n); //将%d的n转换成字符串存入到str中11 int size = strlen(str);12 for(int ix = 1; ix != size; ++ix) ...
阅读全文
摘要:一下是C++Primer中“流状态的查询和操作”的例题: 1 #include<iostream> 2 #include<limits> 3 using namespace std; 4 5 int main() 6 { 7 int ival; 8 while(cin >> ival, !cin.eof()) //必须输入两个文件结束符才可以结束输入??? 9 {10 if(cin.bad()) //input stream is corrupted; bail out11 throw runtime...
阅读全文
摘要:1、进入当前目录的子目录:cd xxx2、放回到当前目录的上一子目录:cd..3、返回到根目录:cd/5、进入到指定目录:先键入指定目录的本目录如D盘:D: 然后回车键入cd xxx\xxx\xxx\xxx\xxx如图:4、强制终止进程: taskkill /f /im xxx.exe 或 tskill xxx(这个没有后缀)以下是我VC中一个程序的无限循环,我想把它结束,按上面的方法:5、键入taskkill /? 查询taskkill的所有用法6、dos 下的清屏命令是 cls将屏幕上的字符清掉,提示符回到桌面左上角
阅读全文
摘要:插入排序:数组或容器中vec[0....n]中,包含了n个待排序的数。输入的各个数字是原地排序的,意即这些数字就是在数组或容器vec在中进行重新排序的,在任何饿时候,至多只有其中的常数个数字是存储在数组或容器之外的。 #include<iostream>#include<vector>using namespace std;int main(){ vector<int> ivec; i...
阅读全文
摘要:问题描述:输入两数,统计两数相加的进位个数My Code://精简代码#include<iostream>using namespace std;int main(){ int a, b, c, cnt; while(cin >> a >> b) { c = cnt = 0; while(a || b) { c = ((a%10 + b%10 + c) > 9) ? 1 : 0; cnt += c; a /= 10; b /= 10; } ...
阅读全文
摘要:题目描述://--------------------C_Style---------------- #include<stdio.h> #include<string.h> int main() { char word[100]; scanf("%s", word); int len = strlen(word); for(int i = 1; i <= len; ++i) if(len % i == 0) { int ok = 1; for(int j = i; j <...
阅读全文
摘要:1 //------------C_Style----------------- 2 3 #include<stdio.h> 4 5 void main() 6 { 7 char *str = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./"; 8 int c; 9 printf("Enter a string(Ctr+Z to end):\n");10 while((c = getchar()) != EOF)11 {12 for(int ix = 1; str[ix] &
阅读全文
|