这个程序是不是语法结构有问题啊?

问题描述:

这个程序是不是语法结构有问题啊?
我做的一个joseph环程序,一直有问题,语法没有错,但是已运行就要弹出来,于是我就做了一个简单的版本主要是看看我的show函数是不是有问题,但是发现的是问题更奇怪……调试的时候说的是head->next=a1;这一句内存写入冲突,高人看看是不是我的语法结构本来就有问题啊?谢谢…………
源程序如下:
// tryjoseph.cpp :Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream.h"
struct queen
{
int num;
struct queen *next;
};
void show(struct queen *head,int step)
{
int i,j=1;
struct queen *temp,*temp2=NULL;
temp=head->next;
while(temp->next!=temp)
{
for(i=0;inext;
}
coutnum=1;
a1->next=a2;
a2->num=2;
a2->next=a3;
a3->num=3;
a3->next=a4;
a4->num=4;
a4->next=a1;
cout
1个回答 分类:综合 2014-11-24

问题解答:

我来补答
#include "iostream.h"
struct queen
{
int num;
struct queen *next;
};
void show(struct queen *head,int step)
{
int i,j=1;
struct queen *temp,*temp2=NULL;
temp=head->next;
while(temp->next!=temp)
{
for(i=0;inext;
}
coutnext=a2;
a2->num=2;
a2->next=a3;
a3->num=3;
a3->next=a4;
a4->num=4;
a4->next=a1;
cout
 
 
展开全文阅读
剩余:2000
下一页:铜,及其化合物