C/C++ 第6页
计算机专业敲门砖。
【C】while(y--);/while(y++);最终y是多少? - AI科研 编程 读书笔记 - 小竹の笔记本

【C】while(y–);/while(y++);最终y是多少?

while(y--) #include <stdio.h> int main(){ int y=10; while(y--); printf('%d',y); return 0; } 答案:无论y一开始是多少,最终y都等于-1。 为什么? 因为非0即真+对于一个数如果一直+或者...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo2年前
01598
【模拟】各位相加 - 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
【C】大一上期末考纲 - AI科研 编程 读书笔记 - 小竹の笔记本

【C】大一上期末考纲

SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
015615
【递归】反转链表 - AI科研 编程 读书笔记 - 小竹の笔记本

【递归】反转链表

/** * Definition for singly-linked list. * struct ListNode { *     int val; *     struct ListNode *next; * }; */ struct ListNode* reverseList(struct ListNode* head) {    stru...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
01555
【C++】过河卒问题 - AI科研 编程 读书笔记 - 小竹の笔记本

【C++】过河卒问题

无马情况 #include <iostream> // 定义棋盘大小 #define MAXSIZE 30 using namespace std; int main(){ int a[MAXSIZE][MAXSIZE]={0}; int n,m; // n,m为B点的坐标,A点默认为(0,0) cin >> n...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
015514
【递归】斐波那契数 - 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