c/c++
被门夹过的核桃还能补脑么
这个作者很懒,什么都没留下…
展开
-
c语言回顾(六)
1.递归 斐波那契数列#include int fibonaci(int i){ if(i == 0) { return 0; } if(i == 1) { return 1; } return fibonaci(i-1) + fibonaci(i-2);}int main(){ int i;原创 2018-01-22 12:13:23 · 207 阅读 · 0 评论 -
c++回顾(五)——面向对象
1 类 protected: 保护成员变量或函数与私有成员十分相似,但有一点不同,保护成员在派生类(即子类)中是可访问的。私有成员在子类中不可访问。 继承: 1.public 继承:基类 public 成员,protected 成员,private 成员的访问属性在派生类中分别变成:public, protected, private 2.protected 继承:基类 publi...原创 2018-02-13 21:16:46 · 220 阅读 · 0 评论 -
c++回顾(六)
1 继承 一个派生类继承了所有的基类方法,但下列情况除外: 基类的构造函数、析构函数和拷贝构造函数。 基类的重载运算符。 基类的友元函数。 虚拟继承:#include <iostream>using namespace std;//基类class D{public: D(){cout<<"D()"<<endl;} ...原创 2018-02-16 13:02:35 · 181 阅读 · 0 评论 -
c++回顾(七)
三维数组 动态分配内存int ***array;// 假定数组第一维为 m, 第二维为 n, 第三维为h// 动态分配空间array = new int **[m];for( int i=0; i<m; i++ ){ array[i] = new int *[n]; for( int j=0; j<n; j++ ) { ar...原创 2018-03-01 22:01:11 · 185 阅读 · 0 评论 -
c专家编程
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21原创 2018-03-14 10:28:56 · 202 阅读 · 0 评论 -
c++标准输入输出流(二)
4.文件流类 void open(const char * filename ,openmode mode); filename 是文件名,如果缺少路径,则默认为当前目录。 例子:ifstream file1; file1.open("grade.txt,ios::in);//ios::in可以省略,因为ifstream本来是用来输入的; o...原创 2018-05-17 16:55:57 · 546 阅读 · 0 评论 -
c++标准输入输出流(三)
#include <iostream>#include <fstream>#include <string>#include <cstdlib>#include <ctime>using namespace std;class Card{public: string suit;//花色 stri...原创 2018-05-17 22:04:15 · 193 阅读 · 0 评论 -
c++ 类的编写
以此题为例 分析:函数,数据 设计 定义类 由构造函数开始原创 2018-05-11 18:37:14 · 5863 阅读 · 0 评论 -
【北大c++】c++ 重载、输入输出流、强制转换
输入输出流运算符的重载 输入输出流 注:强制转换符的重载,把cin转换成int cin.getline()一行行地读取数据 强制转换 注:指针占用内存,32位机4字节,64位机8字节 这种转换的理解画内存图理解,推导结果。...原创 2018-05-11 18:56:59 · 577 阅读 · 0 评论 -
c++标准输入输出流(四)
#include <iostream>#include <fstream>#include <cstring>using namespace std;class wordtype{ char word[20]; int count;};int getwords(wordtype *w){ ifstream ...原创 2018-05-18 14:43:52 · 157 阅读 · 0 评论 -
2018.5.15 c语言中的困惑
问题: windows下打印的结果是什么?我开始认为是ascii码,实际是输出13 给a赋值看看结果 结果是9 因此我推断我输入的字符a没传到&a里去,可能是scanf没有进行类型转换,类型不统一,直接不接受输入 验证下:/*显示a的存储区域中存放的值*/void dump(const unsigned char *buf, int size) { ...原创 2018-05-15 15:17:34 · 272 阅读 · 0 评论 -
c++标准输入输出流(一)
课程地址:https://www.icourse163.org/learn/XJTU-46006#/learn/content?type=detail&id=1003714708&cid=1004429786&replay=true 1. 流是指从一个位置向另一个位置传输的一连串数据的集合。 补充:流可以理解为一个队列。 在输入输出过程中,会在内存中为每一个数据流开...原创 2018-05-15 20:28:52 · 691 阅读 · 0 评论 -
模板和标准模板库
模板和标准模板库原创 2018-05-30 19:48:52 · 247 阅读 · 0 评论 -
c++回顾(四)
1 引用 **引用 和 指针的区别: 引用很容易与指针混淆,它们之间有三个主要的不同: 不存在空引用。引用必须连接到一块合法的内存。 一旦引用被初始化为一个对象,就不能被指向到另一个对象。指针可以在任何时候指向到另一个对象。 引用必须在创建时被初始化。指针可以在任何时间被初始化。**int& func() { int q; //! return q; // 在...原创 2018-02-12 20:51:38 · 158 阅读 · 0 评论 -
c++回顾 (三)
1 string类#include <iostream>#include <string>using namespace std;int main (){ string str1 = "Hello"; string str2 = "World"; string str3; int len ; // 复制 str1 到 s...原创 2018-02-12 14:57:27 · 176 阅读 · 0 评论 -
c语言回顾——终章
万丈高楼平地起#include#include#includetypedef struct score{ int ID; char name[5]; int A; int B; int C; int avar;}score;int main(){ score stu[5]; FILE *fp; int原创 2018-01-30 13:40:34 · 193 阅读 · 0 评论 -
c语言回顾(一)
有限的手段,无限的运用。 c语言是我本科阶段入门计算机程序设计时学习使用的语言,当时有很多地方理解不了,对程序的运行的深感奇怪和不解。现如今在自己学完编译原理,计算机组成原理,汇编等计算机课程后,回顾C知识点,顿有一番感悟。 利用异或 ^ 来交换两个数的值,而且不引入其他变量unsigned int a=60; //0011 1100unsigned原创 2018-01-15 21:32:13 · 267 阅读 · 0 评论 -
c语言回顾(七)
回顾并加深对c语言标准库的理解和运用原创 2018-01-22 12:42:23 · 250 阅读 · 0 评论 -
c语言回顾(二)
当年学习c语言时,指针是让我困惑很久的部分。后来了解了程序在计算机中是如何存储并执行的,豁然开朗,不甚兴奋。 以下代码来自菜鸟教程和作者手打 言简意赅: 指针是一个变量,其值为另一个变量的地址 1 递增一个指针#include const int MAX = 3;int main (){ int var[] = {10, 100, 200}; int i原创 2018-01-16 21:51:02 · 258 阅读 · 0 评论 -
c语言回顾—练习
1.判断一个数是否可以分解为两个素数之和#include#includeint isPrime(int x);int main(){ int num=0,x=1,flag=0; printf("Please enter an integer(must be greater than 1):"); scanf("%d",&num); if(num1)原创 2018-01-23 20:51:48 · 284 阅读 · 0 评论 -
c语言回顾—练习
4.用结构体实现复数相加#include typedef struct complex{ float i; float j;}complex;int main(int argc, char const *argv[]){ complex a,b; printf("Please enter a complex:\n"); printf("原创 2018-01-24 14:51:41 · 182 阅读 · 0 评论 -
c语言回顾(三)
温故而知新原创 2018-01-17 15:06:35 · 379 阅读 · 0 评论 -
c语言回顾—练习 数组与指针
昨天最后一道转置矩阵没能用二维数组函数传递实现,今天补上,第一个为正确的写法,第二个为找错误原因在原来的基础上修改成3*3数组转置原创 2018-01-24 11:01:35 · 198 阅读 · 0 评论 -
c语言回顾—数组与指针
**http://home.netcom.com/~tjensen/ptr/ch9x.htm**#include //Array and pointer written by Mr Dingint main(){ int a[2][2]; a[0][0]=0; a[0][1]=1; a[1][0]=2; a[1][1]=3; printf("%原创 2018-01-26 22:45:53 · 215 阅读 · 0 评论 -
c语言回顾(四)
1.typedeftypedef unsigned char byte;//byte代替单字节2.输入/输出/*注意字符串的输入和输出#include int main( ) { char str[100]; int i; printf( "Enter a value :"); scanf("%s %d", str, &i); printf(原创 2018-01-19 19:58:44 · 221 阅读 · 0 评论 -
c语言回顾(五)
1.预处理器 #ifndef MESSAGE #define MESSAGE "You wish!"#endif#undef FILE_SIZE#define FILE_SIZE 42#include #define message_for(a, b) \ printf(#a " and " #b ": We love you!\n")int原创 2018-01-19 21:10:44 · 292 阅读 · 0 评论 -
c语言回顾——练习
如无必要,勿增实体 1.求s=a+aa+aaa+aaaa+aa…a的值,其中a是一个数字。#include int main(int argc, char const *argv[]) { int a=0,n=1,p=0,i,sum=0; printf("Enter"); scanf("%d%d",&a,&n); for(i=1;i<=n;i++){原创 2018-01-28 22:19:23 · 235 阅读 · 0 评论 -
c++回顾(二)
1 逻辑与&&#include <iostream>using namespace std;int main(){ int a=0; if(0&&(a=10)>5) cout<<a<<endl; else cout<<a<<原创 2018-02-10 18:17:54 · 211 阅读 · 0 评论 -
c++回顾(一)
2018/2/9 The first day of the winter holiday in my hometown.Review c++ and record attention points.1.enum#include <iostream>using namespace std;enum time { first,second, third,...原创 2018-02-09 20:47:32 · 301 阅读 · 0 评论 -
c语言透视和linux C编程一站式的ELF内容
C一· Vim二·Gcc 编译的背后预处理在命令行定义宏编译语法检查编译器优化生成汇编语言文件汇编ELF文件初步可重定位文件Linux 可重定位文件 ELF结构链接和可执行文件一· Vim1.把 C 语言输出为 html命令模式下的 TOhtml 命令可把 C 语言输出为 html 文件,结合 syntax把 Vim 打造成源代码编辑器15on ,可产生比较好的网页把代码发布出去。2....原创 2018-10-13 09:42:28 · 478 阅读 · 0 评论