C/C++共64篇
计算机专业敲门砖。
【C】printf()中的变量自增自减 - AI科研 编程 读书笔记 - 小竹の笔记本

【C】printf()中的变量自增自减

#include<stdio.h> int main(){ int i=5; printf('%d %d %d %d %d',--i,++i,i++,--i,i++); return 0; } 如以上代码,输出为什么会是6 6 5 6 5呢? 首先将printf后面的参数从左至右依次放入参...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo2年前
026116
【数据结构】邻接多重表C++实现(含DFS,BFS,弗洛伊德算法) - AI科研 编程 读书笔记 - 小竹の笔记本

【数据结构】邻接多重表C++实现(含DFS,BFS,弗洛伊德算法)

#include <iostream> using namespace std; // 边(Edge)节点 // T这个自定义类型就是弧上数据的类型,也就是info的类型。如果边上要存权值,可以设置为int,double等等 template<typena...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
012415
【C++】我的C++笔记 - AI科研 编程 读书笔记 - 小竹の笔记本

【C++】我的C++笔记

笔记写在语雀了,在本站提供PDF文档下载
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo2年前
018815
【C】大一上期末考纲 - AI科研 编程 读书笔记 - 小竹の笔记本

【C】大一上期末考纲

SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
015315
【C++】数据输入检测 - AI科研 编程 读书笔记 - 小竹の笔记本

【C++】数据输入检测

void List::createContacts() { int num=0,num2=0; while(1){ system('cls'); cout << '==========================' << endl; cout << '[   通讯录——创建联系人   ]' &l...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo2年前
012415
【C】使用函数递归实现顺序数组二分查找 - AI科研 编程 读书笔记 - 小竹の笔记本

【C】使用函数递归实现顺序数组二分查找

#include <stdio.h> int BinarySearch(int r[],int low,int high,int k){ int mid; if (low>high){ //若找不到,则返回-1,这也是递归终止条件 return -1; } else{ mid=(low+high)/2; //在顺...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
016915
【递归】斐波那契数 - AI科研 编程 读书笔记 - 小竹の笔记本

【递归】斐波那契数

#include<iostream> using namespace std; int fib(int n){ if (n<2){ return n; } return fib(n-1) + fib(n-2); } int main(){ int n; cin >> n; cout << fib(n); return 0; } 数...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
014715
【C】判断回文数 - AI科研 编程 读书笔记 - 小竹の笔记本

【C】判断回文数

#include <stdio.h> bool fun(int n) { int a = 0; int num = n; while (n > 0) { a = a * 10 + n % 10; n = n / 10; } if (a==num) { return true; } else { return false; } } int main() ...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo2年前
09115
【C】求整数所有因子 - AI科研 编程 读书笔记 - 小竹の笔记本

【C】求整数所有因子

#include <stdio.h> int main(){    int n;    scanf('%d',&n); printf('%d=',n); //默认使用2开始计算    for (int i=2;i<=n;i++){   //直到n不能被整除        while (n...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo2年前
08415
【C】保留几位有效数字 - AI科研 编程 读书笔记 - 小竹の笔记本

【C】保留几位有效数字

使用%.6g!! 例子 #include<stdio.h> double getBMI(float m,float h){ return (m/(h*h)); } int main(){ double m,h; scanf('%lf %lf',&m,&h); float BMI=getBMI(m,h); if (BMI<...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo2年前
010315
【C】质数(素数)判断函数 - AI科研 编程 读书笔记 - 小竹の笔记本

【C】质数(素数)判断函数

代码片段 int isPrime(int x){    //一开始让ret=1,默认是素数    int ret = 1;    int i;    if (x==1||x==0){        //0和1不是素数        ret = 0;        return re...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo2年前
029115
【深基2.习6】Apples Prologue / 苹果和虫子 - AI科研 编程 读书笔记 - 小竹の笔记本

【深基2.习6】Apples Prologue / 苹果和虫子

题目描述 八尾勇喜欢吃苹果。她现在有m(1<=m<=100)个苹果,吃完一个苹果需要花费 t(0<=t<=100)分钟,吃完一个后立刻开始吃下一个。现在时间过去了s(1<=s<=10000)分钟,...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo2年前
08515