Practice Code
Tangbzh
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
[自娱自乐]模拟像素打印和位练习
参考文章: http://blog.youkuaiyun.com/sxhelijian/article/details/17167291 原理: 1、按位打印字符,并用32位整型来压缩.(十六进制表示) 2、位操作: 0 & x = 0, 1 | x = 1. 位状态的反转 3、轴对称的利用 #include using namespace std; //digit tabl原创 2014-02-19 15:22:13 · 1102 阅读 · 0 评论 -
[Practice]快速幂求模递归法
Practice原创 2014-04-07 22:48:33 · 1193 阅读 · 0 评论 -
[Pratice]猜生日(书中实例)
原理: 通过5个集合来确定二进制的每一个位,从而确定5位二进制数对应的十进制(2^5-1 = 31) #include #include using namespace std; char set[][53] = { "16 17 18 19\n 20 21 22 23\n 24 25 26 27\n 28 29 30 31", " 8 9 10 11\n 12 13 14转载 2014-03-24 23:05:54 · 743 阅读 · 0 评论 -
[Pratice]简单版桶排序
转自 http://ahalei.blog.51cto.com/4767671/1362789 #include #include using namespace std; //just demo, so there isn't more function int main(int argc, char const *argv[]) { int value[] = {9, 1,转载 2014-04-02 21:32:43 · 663 阅读 · 0 评论 -
[Pratice]文本自动对比
鉴于,今天的实验课作业,输出的小小误差,令我失分。 我觉得很可惜,但是每次都讲输出和Example Output人工对比,令我好烦。 #include #include #include using namespace std; /*Funtion: determine if two file text is the same. Otherwise, point out the原创 2013-12-16 19:14:53 · 792 阅读 · 0 评论 -
[Practice]冒泡排序的有趣实现
来源:http://blog.youkuaiyun.com/morewindows/article/details/6657829 本文是对其理解 #include using namespace std; //常规,假定序列中不存在有序的 void bubble1(int arr[], int n) { for (int i = 0; i < n-1; ++i) for (in转载 2014-04-17 10:36:45 · 626 阅读 · 0 评论 -
[Practice]关于数字电路的一个问题
假定有7个输入端口,有2种输入状态:1(有效)、0(无效)。端口编号分别为0~7,编号越大优先级越高,请设计一个电路来筛选出有效端口中优先级最高的那一个。 (输出端口也是有7个,端口编号分别为0~7。每次输出都只有一个端口有效,其余无效,而这个有效端口的编号为筛选结果) 个人做法: 有效端口中优先级最高的那个端口,一定不存在优先级更高的有效端口原创 2014-04-15 21:42:14 · 625 阅读 · 0 评论 -
[Homework]数字电路设计,显示学号后四位
总结: 必须认真看说明书,各种坑。原创 2014-04-29 21:18:30 · 4684 阅读 · 0 评论 -
[Pratice]八皇后问题
想要真正理解,就实践,身临其境。 #include using namespace std; //n皇后的设定值 const int COLUMN = 8; int queen[COLUMN]; /*判断当前列以上是否冲突,即对角线和列检查 *而行数偏移量与对角线的关系,可以归纳得出 */ bool isValid(int row, int col) { for (int i = 1原创 2014-02-28 23:35:23 · 665 阅读 · 0 评论 -
[Practice]算术表达式
import java.util.Scanner; class A { public static void main(String[] args) { Scanner in = new Scanner(System.in); int times = in.nextInt(); int sum = 0;原创 2014-04-09 20:08:46 · 640 阅读 · 0 评论 -
Clock for Android
闹钟应用 http://download.youkuaiyun.com/detail/tbz888/7372107原创 2014-05-19 23:01:16 · 566 阅读 · 0 评论 -
[Practice]二进制的奇偶位互换
题目:原创 2014-07-16 23:53:05 · 723 阅读 · 0 评论 -
[Practice]运算器
加减乘除 与或非、异或原创 2014-06-12 20:34:15 · 663 阅读 · 0 评论 -
[Practice]给定链表的头指针和结点指针,在O(1)时间删除该结点
题目: 给定链表的头指针和一个结点指针,在O(1)时间删除该结点。链表结点的定义如下: struct ListNode { int m_nKey; ListNode* m_pNext; }; 分析:原创 2014-06-12 22:53:13 · 669 阅读 · 0 评论 -
[Practice]求二进制位串中1的个数
如题,常规做法暂不说。 妙解: 1、原创 2014-06-10 22:29:13 · 624 阅读 · 0 评论 -
[Practice]带最值函数的栈
题目: 自定义栈的数据结构,push要求添加一个min函数,能够得到栈的最小元素。要求时间复杂度都是O(1)。原创 2014-06-08 14:22:56 · 624 阅读 · 0 评论 -
[Practice]求和为100的组合个数
题目: biancheng原创 2014-06-08 10:24:59 · 1271 阅读 · 0 评论 -
[Practice]找出丢失的一个数
题目: 提供一个函数getBit()原创 2014-07-16 23:39:03 · 639 阅读 · 0 评论 -
[Practice]对栈排序
题目: 将一个栈升序排序原创 2014-07-16 23:33:46 · 689 阅读 · 0 评论 -
[Pratice]递归形式的暴力破解。
。原创 2014-01-24 17:20:13 · 761 阅读 · 0 评论 -
[个人理解]一个可以帮助理解数组名的小程序
个人的理解原创 2013-11-24 12:27:24 · 1344 阅读 · 0 评论 -
[Failed Practice]Suffix Expression
#include #include #include #include #include using namespace std; bool isDigit(char c) { return (c = '0'); } const char allOperator[] = "+-*/^^()"; bool isOperator(char c) { for (int j = 0;原创 2014-01-28 13:41:41 · 284 阅读 · 0 评论 -
[Temp]Homework
#include #define increase 1.05 int main(void){ int fee = 10000; for (int i = 1; i <= 10; ++i){ printf("The %d tuition is %d\n", i, fee); printf("The total tuitions are %d\n", 4 * fee); fee *原创 2013-12-09 00:07:54 · 392 阅读 · 0 评论 -
[Practice]在文件中实现字符串查找.
#include #include #include #include using namespace std; int main() { bool state = 0; int line = 0; char c[1000] = {0}, key[1000] = {0}; cout << "Please enter your key :" << endl; cin >> ke原创 2013-12-02 14:05:26 · 612 阅读 · 0 评论 -
[期末小项目]通讯录,basic version
#include #include #include using namespace std; //what a lonely project 2013-11-11 20:48:12 to 2013-11-13 18:36:16 //define a data stype - contact struct contact{ bool existence; int index; cha原创 2013-11-13 21:42:40 · 934 阅读 · 0 评论 -
[练习]统计字符串的小写字母出现次数
#include #include using namespace std; //character occurance statistics int main(){ string operand; cin >> operand; int chn[26]; for (int i = 0; i < 26; ++i) chn[i] = 0; for (int i = 0; i <原创 2013-11-04 13:51:43 · 732 阅读 · 0 评论 -
【练习】ASCII 转换
#include #include #include int main(void) { char ch; printf("请输入一个字符:\n"); ch = getch(); printf("%c -> %d \n\n\n\n\n",ch,ch); system("echo 若重复使用"); system("pause"); system("cls"); sy原创 2013-09-23 14:55:07 · 301 阅读 · 0 评论 -
[书中例题]浮点数陷阱
#include int main(){ double i; for (i=0;i != 10;i+=0.01) printf("%.11f\n",i); } //虽然很简单,但是较好体现了浮点数误差。转载 2013-11-04 19:44:08 · 567 阅读 · 0 评论 -
【练习】十进制转换二进制
#include #include using namespace std;//2013年9月21日23:15:36void two(int a){int c=0,y =0,z;int x[16];for (int b=0;b<16;++b){x[b] = 0;}while (y != 1) { //当时这里出错,想了很久。 z = a%2; //原因是 (y = 1),是不可能继续运行的,所以卡原创 2013-09-23 14:48:37 · 414 阅读 · 0 评论 -
[Pratice]简易计算器
#include int main(int argc, char const *argv[]) { char expression[2][30] = {0}; scanf("%s", expression[1]); for (int i = 0; i < 30; ++i){ if (expression[1][i]) expression[0][i] = 1; } i原创 2013-12-13 20:41:21 · 114 阅读 · 0 评论 -
【Practice】简易计算器
#include int main(int argc, char const *argv[]) { char expression[2][30] = {0}; scanf("%s", expression[1]); for (int i = 0; i < 30; ++i){ if (expression[1][i]) expression[0][i] = 1; } i原创 2013-12-13 21:29:22 · 444 阅读 · 0 评论 -
【练习】(Improved)进制转换
/* 短除法 、 X进制^n */ //时间60进制 二进制,八进制 //缺陷 : 不适用于 含有A-F的十六进制数据 #include using namespace std; void change (int original,int format){ int tmp[16]; int k = 0; for (;k<16;++k){ //不能忘记数组初始化 tmp原创 2013-09-30 14:04:57 · 312 阅读 · 0 评论 -
[Practice]Recursion (Continued)
#include #include using namespace std; /* abstract concretization */ int pow(int x, int n){ if (!n) return 1; return (x * pow(x, n - 1)); } int fib(int index){ if (index < 0) return -1; if (!in转载 2014-01-24 22:49:53 · 655 阅读 · 0 评论 -
[题目]链条问题/切木块
Problem: 假定一段长度为i的钢条的价格为pi(I= 1, 2, …), 表格如下 长度i 1 2 3 4 5 6 7 8 9 10 价格pi原创 2014-01-07 19:50:33 · 839 阅读 · 0 评论 -
[题目]链条问题/切木块
#include #include #include using namespace std; int price_count = 6; bool record[20] = {0}; int max_price(int *price, int length) { if (length == 1) return price[1]; if (len原创 2014-01-06 22:41:02 · 116 阅读 · 0 评论 -
[Pratice]欺骗_库函数
#include #include using namespace std; template void print(T* p) { int k = 0; for (int i = 0; p[i]; ++i) { cout ++k; if (k % 10) cout原创 2014-01-06 16:05:58 · 635 阅读 · 0 评论 -
[Pratice]dynamic_array
#ifndef LIST #define LIST //dynamic array 2013年12月30日21:11:36 template class List { public: List(int); void initialize(T); void clear(); T at(int index); void assign(int, const T); int find(T d原创 2013-12-30 21:13:55 · 463 阅读 · 0 评论 -
[Pratice]LinkedList
#ifndef LINKEDLIST #define LINKEDLIST //非循环单链表 template struct Node { T data; Node* next; }; template class LinkedList { public: LinkedList(int); T read(int); void write(int, T); bool insert原创 2014-01-02 15:59:11 · 418 阅读 · 0 评论 -
[Pratice]dynamic_array练习
#ifndef LIST //List.h#define LIST//dynamic array 2013年12月30日21:11:36template class List{public:List(int);void initialize(T);void clear();T at(int index);void assign(int, const T);int find(T data) cons原创 2013-12-30 21:11:44 · 115 阅读 · 0 评论 -
【水题看法】连续阶乘之和
#include int main() { float s=0,t=1; //浮点数 int n; for(n=1;n<=20;n++) { t=t*n;//∵n! = n * (n-1)! s=s+t; } printf("1!+2!+3!+……+20!=%e\n",s); } 比求出 1! 2! 3! ……n!再相加,运算次数少。原创 2013-11-20 18:54:15 · 341 阅读 · 0 评论
分享