![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C/C++
autuan_liu
有梦想不可怕,可怕的是有了梦想而没有坚持!
展开
-
振兴中华
振兴中华才疏学浅,资历欠佳,难免有误,望有心人批评指正。小明参加了学校的趣味运动会,其中的一个项目是:跳格子。地上画着一些格子,每个格子里写一个字,如下所示: 从我做起振 我做起振兴 做起振兴中 起振兴中华 比赛时,先站在左上角的写着“从”字的格子里,可以横向或纵向跳到相邻的格子里,但不能跳到对角的格子或其它位置。一直要跳到“华”字结束。要求跳过的路线刚好构成“从我做原创 2016-03-09 11:13:51 · 310 阅读 · 0 评论 -
斐波那契数列的两种实现方法
/* * 使用数组的方式实现 斐波那契数列 * */#include <stdio.h> const int N = 1001;int main() { int fi[N]; fi[0] = 1; fi[1] = 1; for (int i = 2; i < N; ++i) { fi[i] = fi[i-1] + fi[i-2]; }原创 2017-03-19 22:04:01 · 426 阅读 · 0 评论 -
实现字符串对换的两种方法
/* * 实现字符串对换的两种方法 * */ #include <iostream> #include <string> using namespace std;void swapstr1(string &str1, string &str2) { string temp; temp = str1; str1 = str2; str2 = temp; }void s原创 2017-03-19 22:02:22 · 1524 阅读 · 0 评论 -
实现两个int 型数据交换的三种方法
/* * 实现两个int 型数据交换的三种方法 * */#include <iostream> using std::cout; using std::endl; using std::cin;//借助临时变量 void swapint1(int &a, int &b) { int temp = a; a = b; b = temp; }//借助加减法实现 void swa原创 2017-03-19 22:00:18 · 2283 阅读 · 0 评论 -
素数筛算法
/* * 素数筛算法 */ #include <iostream> using namespace std;const int N = 1000; int prime[N]; //存储素数的数组 int size = 0; //用于素数的计数 bool isPrime[N+1]; // 用于标记void init() { for (int i = 0; i < N + 1; ++i)原创 2017-03-19 21:59:39 · 366 阅读 · 0 评论 -
二分幂法求x^n
/* * 二分幂法 求x^n */#include <iostream> using std::cin; using std::cout; using std::endl;double powerf(double x, unsigned n) { double ans = 1.0; while (n != 0) { if (n % 2 == 1)原创 2017-03-19 21:59:07 · 714 阅读 · 0 评论 -
最大公约数&&最小公倍数
//最大公约数-递归形式 #include <stdio.h> int gcd(int a,int b) { if(b == 0) return a; else return gcd(b,a%b); } int main() { int a,b; while(scanf("%d%d",&a,&b) != EOF) {原创 2017-03-19 21:58:14 · 425 阅读 · 0 评论 -
求阶乘的两种方法
/* * 求阶乘的 预处理法 */ #include <iostream> using namespace std; const int N = 1000;int main() { int a[N]; a[0] = 1; for (int i = 1; i < N; ++i) { a[i] = i * a[i-1]; } int n;原创 2017-03-19 21:56:18 · 2434 阅读 · 0 评论 -
数字拆解
//特殊乘法#include <stdio.h> int main() { int a,b; while(scanf("%d%d",&a,&b) != EOF) { int buf1[20],buf2[20],size1 = 0,size2 = 0; do { buf1[size1++] = a % 10原创 2017-03-19 21:54:52 · 1211 阅读 · 0 评论 -
将 2进制整数转化为十进制输出到文件中
/* * 将 2进制整数转化为十进制输出到文件中 * 文件的输出练习 * by AutuanLiu */ #include <iostream> #include <fstream> #include <ctime> #include <cstdlib> using namespace std;int trans(int bi) { int weight = 1; int sum原创 2017-03-19 21:51:13 · 330 阅读 · 0 评论 -
int to string
/* * int to string *///使用库函数#include <iostream> #include <cstdlib> using std::cout; using std::cin; using std::endl;int main() { int a;//use 0 to stop while (cin >> a && a != 0) {原创 2017-03-19 21:48:15 · 222 阅读 · 0 评论 -
输入 1 x 2 y z 3 d h 4 g 5,输出 54321
/* * 输入 1 x 2 y z 3 d h 4 g 5,输出 54321 */#include <iostream> #include <cstring> using namespace std;const int N = 1000; int strint(char *str) { int sum = 0; int array[N]; int size = 0;原创 2017-03-19 21:45:58 · 403 阅读 · 0 评论 -
字符串转为整数或浮点数
/* * 字符串转为整数或浮点数 * by AutuanLiu */// 使用库函数#include <iostream> #include <cstdlib> using std::cin; using std::cout; using std::endl;int main(int argc, char const *argv[]) { char _int[30]; char _原创 2017-03-19 21:44:01 · 1336 阅读 · 0 评论 -
字符串子串的查找
/* * 实现字符串子串的查找 */#include <iostream> using namespace std;char *strstr(char *src, char *sub) { const char *bp; const char *sp; if (src == NULL || sub == NULL) { return src;原创 2017-03-19 21:40:17 · 361 阅读 · 0 评论 -
使用ppa安装code::blocks16.01
使用ppa安装code::blocks16.01本文说明通过添加ppa安装code::blocks16.01的方法step1:添加ppasudo add-apt-repository ppa:damien-moore/codeblocks-stablestep2:更新sudo apt updatestep3:安装sudo apt install codeblocksstep4:启动,设置默认编译器一原创 2016-05-05 15:28:36 · 1791 阅读 · 0 评论 -
const的位置
const类型限定符才疏学浅,资历欠佳,难免有误,望有心人批评指正。 序号 const类型限定符说明 1 位置 类型关键字的前面 实例 int a,b;const int *p=&a; 说明 p是一个指针变量,指向一个整型常量,则它表明** *p 是一个常量,而 p 不是,由于 *p 是只读的,是不可以在程序中被修改的,所以,一旦将 *p 作为左原创 2016-03-11 10:52:41 · 488 阅读 · 1 评论 -
简易售票系统
简易售票系统才疏学浅,资历欠佳,难免有误,望有心人批评指正。开发工具 开发工具 code::blocks和markdownpad、sphinx流程图制作工具 visio以及gliffy 开发语言 C语言,markdown文本标记语言 程序运行方法 通过点击here或者访问https://github.com/AutuanLiu/Ticket;原创 2016-03-09 11:15:42 · 573 阅读 · 0 评论 -
从文件读入数据将其转化为2进制输出
/* *从文件读入数据将其转化为2进制输出 */#include <iostream> #include <fstream> #include <cmath> using namespace std;long convert(long a) { long sum = 0; int i = 0; while (a != 0) { sum = sum +原创 2017-03-19 21:49:52 · 572 阅读 · 0 评论