主题:约瑟夫环
#include <stdlib.h>
#include <stdio.h>
struct node {
int num;
int we;
struct node *next;
};
void main(void)
{
int i,x,y;
struct node *h,*s;
h=(struct node *)malloc(sizeof(struct node));
s=h;
for(i=0;i<=3;i++){
scanf("%d,%d",&x,&y);
h->num=x;
h->we=y;
h=h->next;}
h->next =s;
int m=3;
while(s){
if(s->num==m){
printf("%d",s->num);
m=s->we;
h->next=s->next ;
s=s->next;}
else
s++;
h++;}
}帮忙看看这个程序的错误,为啥显示没错了还不运行
#include <stdio.h>
struct node {
int num;
int we;
struct node *next;
};
void main(void)
{
int i,x,y;
struct node *h,*s;
h=(struct node *)malloc(sizeof(struct node));
s=h;
for(i=0;i<=3;i++){
scanf("%d,%d",&x,&y);
h->num=x;
h->we=y;
h=h->next;}
h->next =s;
int m=3;
while(s){
if(s->num==m){
printf("%d",s->num);
m=s->we;
h->next=s->next ;
s=s->next;}
else
s++;
h++;}
}帮忙看看这个程序的错误,为啥显示没错了还不运行