01/10/2018, 14:53
Xin giúp đỡ về lỗi code
Tình hình là em tìm không ra lỗi cho code này, em làm bài quản lý sinh viên và muốn so sánh 2 chuỗi mã lớp với nhau, cho đến khi nhập trùng nhau thì sẽ báo lỗi và bắt nhập lại, nhưng khi debug chạy thử thì nhập mã lớp kiểu gì nó cũng báo là nhập trùng nhau. Tìm không hiểu lỗi nên em lên đây nhờ mọi người
http://codepad.org/VL78scyS
#include <iostream>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<mylib.h>
#include<string.h>
#define TRUE 1
#define FALSE 0
#define MAXLOP 300
struct Diem{
char mamonhoc[11];
int lan;
float diem;
};
struct nodediem{
Diem diem;
struct nodediem*next;
};
typedef nodediem*DIEM;
struct sinhvien{
int maso;
char ho[51];
char ten [11];
char malop[9];
char phai[5];
char sdt[12];
};
struct nodesv{
sinhvien sv;
struct nodesv*next;
nodediem*Firstdiem;
};
typedef nodesv *PTR;
struct lop{
char malop[16];
char tenlop[50];
char nienkhoa[6];
PTR firstsv;// tro den phan tu dau cua danh sach sinh vien
};
struct listlop{
int n=0;
lop *nodelop[MAXLOP];
};
void Baoloi (char* S )
{
int x= wherex() ; int y = wherey();
gotoxy(5, wherey()+2);
printf(S) ;
Sleep(2000);
gotoxy(10, wherey()); printf(" ");
gotoxy(x,y);
}
int ktratrung(listlop &dslop, char* malopm )
{
for ( int i =0 ; i <dslop.n ; i++)
if (stricmp(dslop.nodelop[i]->malop,malopm) == 0)return 1;
return -1;
}
void NhapLop (listlop &dslop)
{ lop *l;
while (dslop.n < MAXLOP)
{
printf ("Ma lop :");
fflush(stdin) ;
gets(l->malop);
if (stricmp(l->malop,"")==0) break;
if (ktratrung(dslop,l->malop) >=0)
{
Baoloi("Ma lop ban nhap bi trung. Hay nhap lai.");
continue;
}
printf("Ten lop :"); fflush(stdin) ; gets(l->tenlop);
l->firstsv=NULL;
dslop.nodelop[dslop.n++]=l;
}
if (dslop.n==MAXLOP)
{ printf("DANH SACH LOP DA DAY.") ; getch();
}
}
int main()
{
listlop dslop;
NhapLop(dslop);
getch();
return 0;
}
Bài liên quan