首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
zhangan
2024年3月9日 16:16
击鼓传花 题解:
P1018
回复 0
|
赞 1
|
浏览 1.1k
#include <stdio.h> #include <stdlib.h> typedef struct lnode { // 定义结构体 int data; struct lnode* next; } lnode, * sqlist; lnode* creatnode(int data) { // 创建链表节点 sqlist L = (lnode*)malloc(sizeof(lnode)); if (L == NULL) {...
cideyitanjiu
2024年3月3日 15:31
击鼓传花 题解:使用动态数组vector,以及迭代器iterator
P1018
回复 0
|
赞 0
|
浏览 1.1k
使用动态数组vector,以及迭代器iterator,用arr.erase(it) 删除数组成员,简单高效快捷 #include<stdio.h> #include<vector> using namespace std; int main() { int N; scanf("%d", &N); vector<int> arr; for(int i =...
jenosa
2024年3月1日 20:39
击鼓传花 题解:主要是模拟过程 没有技巧版
P1018
回复 0
|
赞 1
|
浏览 2.0k
#include<iostream> using namespace std; int main(){ struct Node { int n; struct Node * next; }; int N; cin>>N; //构建循环链表 struct Node...
carrot_huan
2024年2月2日 11:13
击鼓传花 题解:
P1018
回复 0
|
赞 1
|
浏览 1.6k
//就按照题目说的用链表实现把 #include #include struct LNode { int data; struct LNode* next; }; int main() { int n; scanf("%d", &n); //先创建循环链表(不带头结点的种) struct LNode...
小王桐学
2024年2月1日 16:29
击鼓传花 题解:C++
P1018
回复 0
|
赞 1
|
浏览 1.7k
#include <stdio.h> #include <stdlib.h> typedef struct node{ int data; struct node* next; }LNode,*LinkList; //初始化无头循环链表 void InitList(LinkList &L,int n) { int i; L = (LNode *)malloc(sizeof(LinkList)); L = NULL; struct node *s,*p; for(i = 1; i <= n; i++...
carrot_huan
2024年1月31日 01:31
击鼓传花 题解:用不带头结点的循环链表(带头结点的太麻烦了)
P1018
回复 0
|
赞 2
|
浏览 1.3k
//就按照题目说的用链表实现把 #include<stdio.h> #include<malloc.h> struct LNode { int data; struct LNode* next; }; int main() { int n; scanf("%d", &n); //先创建循环链表(不带头结点的种) &nbs...
gold-Q
2023年3月23日 20:56
循环链表解决
P1018
回复 0
|
赞 3
|
浏览 6.7k
#include "bits/stdc++.h" #include #include #include using namespace std; #define NUM 3 struct Node { int id; struct Node *next; Node(int x) : id(x), next(NULL){}; }; struct Node* cre...
Hegel
2023年3月21日 11:17
击鼓传花(约瑟夫环)
P1018
回复 0
|
赞 1
|
浏览 3.8k
#include <iostream> using namespace std; //公式f(n,m)=(f(n-1,m)+m)%n int f2(int n, int m) { if (n == 1) return 0; return (f2(n - 1, m) + m) % n; } int main() { int n; cin>>n; cout << f2(n, 3) + 1<< endl; return 0; } 解决约瑟夫环问题,我们采用倒推,我们倒推出:最后剩下的这个...
KeaiXiaoyu
2023年3月8日 22:00
数组实现,使用一个自定义函数挑出每次出去的人
P1018
回复 0
|
赞 1
|
浏览 4.1k
在这道题里,一开始犯了好几个基本的语法错误,代码逻辑上应该是没有问题,所以现在总结一下,也希望能帮到看到的朋友们。 1 、在c++中,将数组全都初始化为1的代码并非像初始化0一样,而是如果定义了a[105]={1},结果就是除了第一位为1,其余全为0,如果不加以重视,很可能就败在这个小细节上(比如我审视了半天都没发现TnT)一下提出几个解决方案: (1)可以将数组定义全为0,然后设置flag为1时为标志,这样就不用在定义数组初始值为1上纠结; (2)利用fill函数,将数组全部填充,fill(start,end,value); (3)利用memset函数:mems...
huangdashuaige
2023年2月16日 14:04
P1018题解 - 链表操作
P1018
回复 0
|
赞 2
|
浏览 4.1k
#include <iostream> using namespace std; typedef struct LNode{ int data; struct LNode *next; }LNode,*LinkList; //建立不带表头结点的循环单链线性表L(尾插法) void CreatListHead(LinkList L,int n){ LinkList p,r; int i; &nbs...
1
...
3
4
5
6
7
题目
击鼓传花
题解数量
63
发布题解
在线答疑
热门题解
1
击鼓传花 题解:循环链表解决
2
击鼓传花 题解:鄙人认为,约瑟夫环问题用队列就是最容易理解的
3
击鼓传花 题解:(C语言、用数组解决)
4
击鼓传花 题解:尾插法循环单链表(纯C)
5
击鼓传花 题解:谁家的古风小孩可爱捏
6
击鼓传花 题解:vector手撕约瑟夫
7
击鼓传花 题解:链表模拟
8
击鼓传花 题解:c++,循环单链表
9
击鼓传花 题解:不使用循环队列,用数组循环的方式来实现
10
击鼓传花 题解: