PDA

View Full Version : مشکل در اجرای لیست پیوندی



farahnaz_karami
شنبه 08 آبان 1395, 11:26 صبح
با سلام
دوستان من از لیست پیوندی و struct در برنامه ام استفاده کردم ولی نمیدونم چرا اطلاعاتی رو که وارد می کنم توسط برنامه خوانده نمی شوند یعنی برنامه ام خروجی نمیده. ممنون میشم راهنمایی بفرمایید. حلقه ورود اطلاعات من بصورت زیر است:
for (int i=0; i<numberofStudents; i++)
{
cout<<"Enter math score of student "<<i<<" :"<<endl;
cin>>math;
cout<<"Enter physics score of student "<<i<<" :"<<endl;
cin>>phy;
Student *newStudent= new Student;
newStudent->setId(i);
newStudent->setMath(math);
newStudent->setPhysics(phy);
newStudent->next=NULL;

if(first==NULL)
{
first= newStudent;
current= newStudent;
}
else
{
current->next= newStudent;

current= newStudent;

}
}