C/C++ 第4页
计算机专业敲门砖。
【模拟】各位相加 - AI科研 编程 读书笔记 - 小竹の笔记本

【模拟】各位相加

#include<iostream> using namespace std; int main(){ int num; cin >> num; while(num>9){ int total=0; while(num!=0){ total+=num%10; num/=10; } num = total; total = 0; } cout <&...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
01526
【C】复合赋值和递增递减 - AI科研 编程 读书笔记 - 小竹の笔记本

【C】复合赋值和递增递减

复合赋值 5个算术运算符,+-*/%,可以和赋值运算符“=”结合起来,形成复合赋值运算符“+=”、“-=”、“/=”和“%=” total += 5; total = total + 5; 注意两个运算符中间不要有空格 total += ...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo2年前
01575
【C】生成指定区间的随机数 - AI科研 编程 读书笔记 - 小竹の笔记本

【C】生成指定区间的随机数

As we all know,生成随机数需要使用srand和rand函数。srand用于初始化随机种子,一般使用当前系统时间作为种子初始化。 写做:srand(time(NULL));或者srand(time(0)); 要想生成指定区间的随机...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
01276
【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++实现)

什么是顺序栈 顺序栈是一种基于数组实现的栈(Stack)数据结构。栈是一种后进先出(Last In, First Out,LIFO)的数据结构,类似于我们日常生活中的堆叠物体,最后放入的元素最先被取出。顺序栈...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
01905
【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
【模拟】旋转矩阵 - AI科研 编程 读书笔记 - 小竹の笔记本

【模拟】旋转矩阵

#include<stdio.h> int main(){ int n; scanf('%d',&n); int a[n][n]; int top=0,down=n-1,left=0,right=n-1,count=1; while(count<=n*n){ for (int i=left;i<=right;i++){ a[top]...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
05910
【C】if-else if-else和switch-case - AI科研 编程 读书笔记 - 小竹の笔记本

【C】if-else if-else和switch-case

if-else if-else #include<stdio.h> int main() { int type=0; scanf('%d',&type); if (type==1) printf('早'); else if (type==2) printf('中'); else if (type==3) printf('晚'); else...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo2年前
016011
【数据结构】双向链表+C语言实现 - AI科研 编程 读书笔记 - 小竹の笔记本

【数据结构】双向链表+C语言实现

新建节点s,插入至第i个节点之前。 找到p,使得p指向第i个节点 p->pre->next=s; ​ s->pre=p->pre; ​ s->next=p; ​ p->pre=s; 删除节点p,或者说删除第i个节点 p->pre->next=p->next; ​ p->n...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
01376
【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年前
010415
【C++】cpp-httplib研究链接 - AI科研 编程 读书笔记 - 小竹の笔记本

【C++】cpp-httplib研究链接

https://github.com/yhirose/cpp-httplib https://blog.csdn.net/qq_40344790/article/details/135246178 https://juejin.cn/post/7169574207632703519 https://www.bilibili.com/video/BV1Xt4y...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
021410
【C】P2415 集合求和 - AI科研 编程 读书笔记 - 小竹の笔记本

【C】P2415 集合求和

集合求和 题目描述 给定一个集合 s(集合元素数量 <=30),求出此集合所有子集元素之和。 输入格式 集合中的元素(元素 <=1000) 输出格式 s 所有子集元素之和。 样例 #1 样例输入 #1 2 3...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo2年前
0665