ysf.cpp

来自「这个小程序是用c++实现的约瑟夫环问题」· C++ 代码 · 共 57 行

CPP
57
字号
#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 + =
减小字号Ctrl + -
显示快捷键?