用DevC++5.4.0编译没问题,一运行就出现exe已停止工作,出现了一个问题,导致程序停止正常工作
代码如下:#include<iostream>
using namespace std;
#define max 10
#include<time.h>
#include<stdlib.h>
template<class t>
struct maxnode
{
int row;
int col;
t value;
} ;
template<class t>
struct spar
{
int m;
int n;
int p;
maxnode<t>data[max];
};
template<class t>
void tran(spar<t>*orig,spar<t>*trans)
{
trans->m=orig->n;
trans->n=orig->m;
trans->p=0;
for(int col=0;col<orig->n;col++)
for(int j=0;j<orig->t;j++)
if(orig->data[j].col==col)
{
trans->data[trans->p].col=orig->data[j].row;
trans->data[trans->p].row=orig->data[j].col;
trans->data[trans->p].value=orig->data[j].value;
trans->t++;
}
}
int main()
{
spar<int>*stu1;
for(int i=0;i<max;i++)
{
srand((unsigned)time(NULL));
stu1->data[i].row=rand()%max;
stu1->data[i].col=stu1->data[i].row+1;
stu1->data[i].value=rand()%100;
stu1->m=rand()%max;
stu1->n=rand()%max+1;
stu1->p=max;
}
for(int k=0;k<max;k++)
{
cout<<stu1->data[k].row<<endl;
cout<<stu1->data[k].col<<endl;
cout<<stu1->data[k].value<<endl;
cout<<stu1->m;
cout<<stu1->n;
cout<<stu1->p;
}
system("pause");
return 0;
}
编译没问题,一 运行就不行了,求各位大神帮忙看看哈(之前就有过因为Dev版本太低所以编译不了,这次换了比较新的也不行,是不是编译器的问题,怎么解决?电脑里边也有装vs2013)