桑海

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
上一页 1 ··· 15 16 17 18 19

2012年11月14日

摘要: 刚开始想直接求出n的阶乘,在从其结果里面查找相应的素数,可是发现数字太大,越界了,经改正如下: My Code: #include<iostream>using namespace std;int prime[100];void prime_array() //生成素数表{ for(int i = 2, k = 0; i < 100; ++i) { int... 阅读全文
posted @ 2012-11-14 21:02 桑海 阅读(256) 评论(0) 推荐(0) 编辑

摘要: 题目分析: 本题是由对角线由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的所行与列... 阅读全文
posted @ 2012-11-14 19:58 桑海 阅读(219) 评论(0) 推荐(0) 编辑

2012年11月13日

摘要: //---------------MY CODE-------------------------#include<iostream>#include<vector>#include<string>using namespace std;string get(string word){ for(int i = 1; i != word.size(); ++i) { ch... 阅读全文
posted @ 2012-11-13 22:55 桑海 阅读(270) 评论(1) 推荐(0) 编辑

摘要: 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) ... 阅读全文
posted @ 2012-11-13 17:00 桑海 阅读(937) 评论(0) 推荐(0) 编辑

2012年11月12日

摘要: 一下是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... 阅读全文
posted @ 2012-11-12 17:08 桑海 阅读(279) 评论(0) 推荐(0) 编辑

摘要: 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将屏幕上的字符清掉,提示符回到桌面左上角 阅读全文
posted @ 2012-11-12 15:15 桑海 阅读(297) 评论(0) 推荐(0) 编辑

2012年11月11日

摘要: 插入排序:数组或容器中vec[0....n]中,包含了n个待排序的数。输入的各个数字是原地排序的,意即这些数字就是在数组或容器vec在中进行重新排序的,在任何饿时候,至多只有其中的常数个数字是存储在数组或容器之外的。 #include<iostream>#include<vector>using namespace std;int main(){ vector<int> ivec; i... 阅读全文
posted @ 2012-11-11 18:51 桑海 阅读(180) 评论(0) 推荐(0) 编辑

2012年11月8日

摘要: 问题描述:输入两数,统计两数相加的进位个数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; } ... 阅读全文
posted @ 2012-11-08 21:29 桑海 阅读(436) 评论(1) 推荐(1) 编辑

2012年11月7日

摘要: 题目描述://--------------------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 <... 阅读全文
posted @ 2012-11-07 20:47 桑海 阅读(239) 评论(0) 推荐(0) 编辑

摘要: 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] & 阅读全文
posted @ 2012-11-07 19:38 桑海 阅读(304) 评论(0) 推荐(0) 编辑

上一页 1 ··· 15 16 17 18 19