llllmz

导航

2024年1月17日

猫狗收容所 C++

摘要: #include<iostream> #include<queue> using namespace std; void delect(queue<int>* q,int x){ if(q->empty()) return; for(int i=0;i<q->size();i++){ int t=q 阅读全文

posted @ 2024-01-17 22:06 神奇的萝卜丝 阅读(27) 评论(0) 推荐(0)

3254:约瑟夫问题No.2C

摘要: 做个循环列表就行了。 逻辑上想想还是很简单的。 然而在实践的时候需要考虑许多边界情况。每次循环的时候要考虑头节点的问题。 #include<stdio.h> #include<stdlib.h> struct node{ int data; struct node* next; }; typedef 阅读全文

posted @ 2024-01-17 21:07 神奇的萝卜丝 阅读(22) 评论(0) 推荐(0)

3254:约瑟夫问题No.2C++

摘要: \ 这题思路还是挺多的。 如果用数学的角度考虑。知道了n,p,m自然就知道下一个要出队的人的编号。然后一个个输出就行了。 还可以用循环链表做。 还可以用队列。出队在入队。 #include<iostream> #include<queue> using namespace std; int main 阅读全文

posted @ 2024-01-17 18:31 神奇的萝卜丝 阅读(62) 评论(0) 推荐(0)

KY20 完数VS盈数C

摘要: 、 #include<stdio.h> int sum(int x){ int sum = 0; for(int i = 1; i < x ;i++){ if(x%i==0) sum+=i; } return sum ; } int main(){ int A[60]={0}; int B[60]= 阅读全文

posted @ 2024-01-17 17:43 神奇的萝卜丝 阅读(43) 评论(0) 推荐(0)

KY20 完数与盈数C++

摘要: 练习使用向量vector容器。 遍历每个数取余就好了。然后记录下来。 #include<iostream> #include<vector> using namespace std; int main() { vector<int> B ; vector<int> C ; for (int i = 阅读全文

posted @ 2024-01-17 17:16 神奇的萝卜丝 阅读(39) 评论(0) 推荐(0)