C/C++ 第2页
计算机专业敲门砖。
【C++】自定义类型还敢用memcpy吗? - AI科研 编程 读书笔记 - 小竹の笔记本

【C++】自定义类型还敢用memcpy吗?

气死我啦!调了一下午+一晚上的bug,结果是因为memcpy浅拷贝问题,给我都整无雨了。 之前一直是引发异常,我debug了一下是到自定义类型析构函数处引发的异常。应该就是释放了已经释放的内存导致...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
0877
【递归】斐波那契数 - 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年前
015515
【模拟】旋转矩阵 - 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年前
06010
【模拟】各位相加 - 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年前
01586
【模拟】二进制求和 - AI科研 编程 读书笔记 - 小竹の笔记本

【模拟】二进制求和

#include <iostream> using namespace std; string addBinary(string a, string b){ string res; int carry = 0;  // 进位 int i = a.size() - 1; int j = b.size() - 1; while(i >= 0 || j...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
014214
【C++】高精度减法 - AI科研 编程 读书笔记 - 小竹の笔记本

【C++】高精度减法

#include <iostream> using namespace std; int main(){ string s1,s2; cin >> s1; cin >> s2; int a1[210]={0}; int a2[210]={0}; int a3[210]={0}; char flag='+'; if (s1.size()<s2.si...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
013413