⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ysf.cpp

📁 这个小程序是用c++实现的约瑟夫环问题
💻 CPP
字号:
#include <stdio.h>
#include <stdlib.h>


typedef struct node
{
	int num;
	int password;
	struct node *next;
}node, *LinkList;

InitList(node *p)
{
	p=(node *)malloc(sizeof(node));
	p->next=NULL;
}

void main()
{
	node *p, *s;
	int NumV;
	int PasswordV;
	int i;

	InitList(p);
	
	for(i=0;i<3;i++)
	{
		printf("Please enter the Number of the people:");
		scanf("%d",&NumV);
		printf("Please enter the Password of the people:");
		scanf("%d",&PasswordV);

		s=(node *)malloc(sizeof(node));
		printf("!!%d",s->num);
		printf("%d",s->password);

		s->num=NumV;
		//printf("!!!!!!");
		//printf("%d",s->num);
		s->password=PasswordV;
		//printf("!!!!!!");
		//printf("%d",s->password);

		s->next=p->next;

		p->next=s;
		
	}

	for(i=0;i<3;i++)
	{
		printf("The number of %d people is %d",i,p->num);
		printf("The password of %d people is %d",i,p->password);
		p=p->next;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -