亲爱的读者,很多人可能对简单的c语言程序大概在200行左右哪位大和c语言编程题不是很了解,所以今天我来和大家分享一些关于简单的c语言程序大概在200行左右哪位大和c语言编程题的知识,希望能够帮助大家更好地了解这个话题。
本文目录一览
- 1、简单的c语言程序,大概在200行左右,哪位大神能帮帮忙,急急
- 2、c语言编程题
- 3、求一C语言高手帮忙做一个200行左右的程序,事成后追加50积分
- 4、C语言:世界杯小组分组
- 5、c语言问题,帮我想想办法
- 6、C语言 输入参加世界杯的32支球队,由计算机产生一份分组名单,每组4支球队
- 7、求一段C语言程序,150-200行,什么都行,做课设用的万分感谢!!!!
- 8、C语言课程设计不少于200行代码
简单的c语言程序,大概在200行左右,哪位大神能帮帮忙,急急
#include《stdio.h》
intmain(intargc,char**argv)
{
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
printf(“helloworld!\n“);
//hehe
}
c语言编程题
这个是因为你的语法错误if{语句}else{语句}要这种方式,你的是if(a《=1000)b=sqrt(a);这句判断就结束了,和后面的else没有关系了。要用{}把后面的语句括起来才可以。
求一C语言高手帮忙做一个200行左右的程序,事成后追加50积分
//ping的实现代码
#include《winsock2.h》
#include《ws2tcpip.h》
#include《stdio.h》
#include《stdlib.h》
#defineIP_RECORD_ROUTE0x7
#defineDEF_PACKET_SIZE32
#defineMAX_PACKET1024//MaxICMPpacketsize
#defineMAX_IP_HDR_SIZE60//MaxIPheadersizew/options
#defineICMP_ECHO8
#defineICMP_ECHOREPLY0
#defineICMP_MIN8//Minimum8-byteICMPpacket(header)
typedefstruct_iphdr
{
unsignedinth_len:4;//Lengthoftheheader
unsignedintversion:4;//VersionofIP
unsignedchartos;//Typeofservice
unsignedshorttotal_len;//Totallengthofthepacket
unsignedshortident;//Uniqueidentifier
unsignedshortfrag_and_flags;//Flags
unsignedcharttl;//Timetolive
unsignedcharproto;//Protocol(TCP,UDPetc)
unsignedshortchecksum;//IPchecksum
unsignedintsourceIP;
unsignedintdestIP;
}IpHeader;
typedefstruct_icmphdr
{
BYTEi_type;
BYTEi_code;//Typesubcode
USHORTi_cksum;
USHORTi_id;
USHORTi_seq;
//Thisisnotthestandardheader,butwereservespacefortime
ULONGtimestamp;
}IcmpHeader;
//
//IPoptionheader-usewithsocketoptionIP_OPTIONS
//
typedefstruct_ipoptionhdr
{
unsignedcharcode;//Optiontype
unsignedcharlen;//Lengthofoptionhdr
unsignedcharptr;//Offsetintooptions
unsignedlongaddr;//ListofIPaddrs
}IpOptionHeader;
intparse(int*parc,char*parv,char*src,intmaxpar)
{
inti=0;
charwillBeWord;
*parc=0;
willBeWord=1;
if(src==NULL)
return0;
while(src!=’\0’&&*parc《maxpar)
{
if(src==’’)
{
willBeWord=1;
src=0;
}
else
{
if((willBeWord》0)&&((src!=0x0A)))
{
parv;
(*parc)++;
willBeWord=0;
}
}
i++;
}
return(*parc);
}
voidFillICMPData(char*icmp_data,intdatasize)
{
IcmpHeader*icmp_hdr=NULL;
char*datapart=NULL;
icmp_hdr=(IcmpHeader*)icmp_data;
icmp_hdr-》i_type=ICMP_ECHO;//RequestanICMPecho
icmp_hdr-》i_code=0;
icmp_hdr-》i_id=(USHORT)GetCurrentProcessId();
icmp_hdr-》i_cksum=0;
icmp_hdr-》i_seq=0;
datapart=icmp_data+sizeof(IcmpHeader);
}
voidDecodeIPOptions(char*buf,intbytes)
{
IpOptionHeader*ipopt=NULL;
IN_ADDRinaddr;
inti;
HOSTENT*host=NULL;
ipopt=(IpOptionHeader*)(buf+20);
//m_dlg-》m_result+=“Ping结果:\r\n“;
for(i=0;i《(ipopt-》ptr/4)-1;i++)
{
inaddr.S_un.S_addr=ipopt-》addr;
host=gethostbyaddr((char*)&inaddr.S_un.S_addr,
sizeof(inaddr.S_un.S_addr),AF_INET);
if(host)
{
printf(“(%-15s)%s\r\n“,inet_ntoa(inaddr),host-》h_name);
}
else
{
printf(“(%-15s)\r\n“,inet_ntoa(inaddr));
}
}
return;
}
USHORTchecksum(USHORT*buffer,intsize)
{
unsignedlongcksum=0;
while(size》1)
{
cksum+=*buffer++;
size-=sizeof(USHORT);
}
if(size)
{
cksum+=*(UCHAR*)buffer;
}
cksum=(cksum》》16)+(cksum&0xffff);
cksum+=(cksum》》16);
return(USHORT)(~cksum);
}
voidDecodeICMPHeader(char*buf,intbytes,SOCKADDR_IN*from)
{
IpHeader*iphdr=NULL;
IcmpHeader*icmphdr=NULL;
unsignedshortiphdrlen;
DWORDtick;
staticinticmpcount=0;
inttm1;
iphdr=(IpHeader*)buf;
//Numberof32-bitwords*4=bytes
iphdrlen=iphdr-》h_len*4;
tick=GetTickCount();
if((iphdrlen==MAX_IP_HDR_SIZE)&&(!icmpcount))
DecodeIPOptions(buf,bytes);
if(bytes《iphdrlen+ICMP_MIN)
{
printf(“Toofewbytesfrom%s\r\n“,inet_ntoa(from-》sin_addr));
}
icmphdr=(IcmpHeader*)(buf+iphdrlen);
if(icmphdr-》i_type!=ICMP_ECHOREPLY)
{
printf(“nonechotype%drecvd\r\n“,icmphdr-》i_type);
return;
}
//MakesurethisisanICMPreplytosomethingwesent!
//
if(icmphdr-》i_id!=(USHORT)GetCurrentProcessId())
{
printf(“someoneelse’spacket!\r\n“);
return;
}
tm1=tick-icmphdr-》timestamp;
if(tm1《1)
printf(“%dbytesfrom%s:icmp_seq=%d.time:《1ms\r\n“,bytes,inet_ntoa(from-》sin_addr),icmphdr-》i_seq);
else
printf(“%dbytesfrom%s:icmp_seq=%d.time:%dms\r\n“,bytes,inet_ntoa(from-》sin_addr),icmphdr-》i_seq,tick-icmphdr-》timestamp);
icmpcount++;
return;
}
intmain(intargc,char*argv)
{
WSADATAwsaData;
SOCKETm_hSocket;
//IpOptionHeaderm_ipopt;
SOCKADDR_INm_addrDest;
SOCKADDR_INm_addrFrom;
charicmp_data;
USHORTseq_no=0;
charch,cmdbuf;
inti=0,parc,nCount=1;
intct=0,bwrote,timeout=1000;
intdatasize=DEF_PACKET_SIZE;
intbread;
intfromlen;
if(WSAStartup(MAKEWORD(2,2),&wsaData)!=0)
{
printf(“Sorry,youcannotloadsocketdll!“);
return-1;
}
/*do{
ch=getchar();
cmdbuf=ch;
}while((ch!=0x0D)&&(ch!=0x0A));
if((cmdbuf==0x0A))
{
cmdbuf;
cmdbuf=’’;
cmdbuf=’\0’;
}
parse(&parc,parv,cmdbuf,sizeof(parv));
if(parc==0)
return0;
for(i=1;i《parc;i++)
{
if(strcmp(parv,“-t“)==0)
{
nCount=0;
}
elseif(strcmp(parv,“-n“)==0&&i《(parc-1))
{
nCount=atoi(parv);
i++;
}
else
{
if(strlen(parv)》6)
{
strcpy(lpdest,parv);
}
}
}*/
for(i=1;i《argc;i++)
{
if(strcmp(argv,“-t“)==0)
{
nCount=0;
}
elseif(strcmp(argv,“-n“)==0&&i《(argc-1))
{
nCount=atoi(argv);
i++;
}
else
{
if(strlen(argv)》6)
{
strcpy(lpdest,argv);
}
}
}
m_hSocket=WSASocket(AF_INET,SOCK_RAW,IPPROTO_ICMP,NULL,0,
WSA_FLAG_OVERLAPPED);
if(m_hSocket==INVALID_SOCKET)
{
printf(“socket创建失败!“);
return-1;
}
//Setthesend/recvtimeoutvalues
//
bread=setsockopt(m_hSocket,SOL_SOCKET,SO_RCVTIMEO,
(char*)&timeout,sizeof(timeout));
if(bread==SOCKET_ERROR)
{
printf(“设置socket接收超时选项错误!“);
return-1;
}
timeout=1000;
bread=setsockopt(m_hSocket,SOL_SOCKET,SO_SNDTIMEO,
(char*)&timeout,sizeof(timeout));
if(bread==SOCKET_ERROR)
{
printf(“设置socket发送超时选项错误!“);
return-1;
}
memset(&m_addrDest,0,sizeof(m_addrDest));
//
//Resolvetheendpoint’snameifnecessary
//
m_addrDest.sin_family=AF_INET;
if((m_addrDest.sin_addr.s_addr=inet_addr(lpdest))==INADDR_NONE)
{
structhostent*hp=NULL;
if((hp=gethostbyname(lpdest))!=NULL)
{
memcpy(&(m_addrDest.sin_addr),hp-》h_addr,hp-》h_length);
m_addrDest.sin_family=hp-》h_addrtype;
//printf(“m_addrDest.sin_addr=%s\n“,inet_ntoa(m_addrDest.sin_addr));
}
else
{
//printf(“gethostbyname()failed:%d\n“,
//WSAGetLastError());
printf(“输入的主机不存在!“);
return-1;
}
}
//
//CreatetheICMPpacket
//
datasize+=sizeof(IcmpHeader);
//icmp_data=(char*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,
//MAX_PACKET);
//recvbuf=(char*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,
//MAX_PACKET);
//if(!icmp_data)
//{
//AfxMessageBox(“堆分配错误!“);
//return;
//}
memset(icmp_data,0,MAX_PACKET);
FillICMPData(icmp_data,datasize);
//
//Startsending/receivingICMPpackets
//
while(1)
{
if(ct++》=nCount)
break;
((IcmpHeader*)icmp_data)-》i_cksum=0;
((IcmpHeader*)icmp_data)-》timestamp=GetTickCount();
((IcmpHeader*)icmp_data)-》i_seq=seq_no++;
((IcmpHeader*)icmp_data)-》i_cksum=
checksum((USHORT*)icmp_data,datasize);
bwrote=sendto(m_hSocket,icmp_data,datasize,0,
(structsockaddr*)&m_addrDest,sizeof(m_addrDest));
if(bwrote==SOCKET_ERROR)
{
if(WSAGetLastError()==WSAETIMEDOUT)
{
printf(“Sendtimedout!\r\n“);
continue;
}
return0;
}
if(bwrote《datasize)
{
printf(“Wrote%dbytes\r\n“,bwrote);
}
fromlen=sizeof(m_addrFrom);
bread=recvfrom(m_hSocket,recvbuf,MAX_PACKET,0,
(structsockaddr*)&m_addrFrom,&fromlen);
if(bread==SOCKET_ERROR)
{
if(WSAGetLastError()==WSAETIMEDOUT)
{
printf(“Recvtimedout!\r\n“);
continue;
}
return0;
}
DecodeICMPHeader(recvbuf,bread,&m_addrFrom);
}
if(m_hSocket!=INVALID_SOCKET)
closesocket(m_hSocket);
WSACleanup();
return0;
}
C语言:世界杯小组分组
我的这个程序是先读入人名与成绩,
然后按先人名再成绩如入:
#include“stdio.h“
longinta=;
charb;//输入最多1000人,每人名字不超过100字符
main()
{longintn;
scanf(“%ld“,&n);
for(i=1;i《=n;i++)
{
scanf(“%s%ld“,&b);
}
然后三个子程序判断成绩就行了,
不写了......
c语言问题,帮我想想办法
#include《stdio.h》
#include《string.h》
#include《stdlib.h》
typedefstructtagTeam{
structtagTeam*next;
charname;
intwins;
intdraws;
intlosses;
intgoal;
intdrop;
intgoalDiff;
intpoints;
}Team;
voidupdateTeam(Team*team,intgoal,intdrop)
{
team-》wins+=goal》drop?1:0;
team-》draws+=goal==drop?1:0;
team-》losses+=goal《drop?1:0;
team-》goal+=goal;
team-》drop+=drop;
team-》goalDiff=team-》goal-team-》drop;
team-》points=team-》wins*3+team-》draws;
}
Team*createEmptyTeam()
{
return(Team*)malloc(sizeof(Team));
}
Team*createTeam(constchar*name,intgoal,intdrop)
{
Team*team=(Team*)malloc(sizeof(Team));
team-》next=NULL;
strcpy(team-》name,name);
team-》wins=0;
team-》draws=0;
team-》losses=0;
team-》goal=0;
team-》drop=0;
team-》goalDiff=0;
team-》points=0;
updateTeam(team,goal,drop);
returnteam;
}
voiddeleteTeam(Team*team)
{
free(team);
}
voidappendTeam(Team**list,Team*team)
{
if(*list!=NULL)
team-》next=*list;
*list=team;
}
Team*findTeam(Team*list,constchar*name)
{
Team*team=list;
while(team!=NULL){
if(strcmp(team-》name,name)==0)
break;
team=team-》next;
}
returnteam;
}
intsaveTeamList(constTeam*list)
{
FILE*file;
constTeam*team;
file=fopen(“standing.bin“,“wb“);
if(file==NULL){
printf(“Failedtoopenthefilestanding.bin\n“);
return1;
}
team=list;
while(team!=NULL){
if(fwrite(team,sizeof(*team),1,file)!=1){
printf(“Failedtosavetheteaminfomation!\n“);
return2;
}
team=team-》next;
}
fclose(file);
return0;
}
intloadTeamList(Team**list)
{
FILE*file;
Teamteam;
file=fopen(“standing.bin“,“rb“);
if(file==NULL){
printf(“Failedtoopenthefilestanding.bin\n“);
return1;
}
while(1){
Team*team=createEmptyTeam();
if(fread(team,sizeof(*team),1,file)==1){
team-》next=NULL;
appendTeam(list,team);
}else{
deleteTeam(team);
break;
}
}
fclose(file);
return0;
}
voidprintTeam(constTeam*team)
{
printf(
“Team:%s\n“
“wins:%d\n“
“draws:%d\n“
“losses:%d\n“
“goal:%d\n“
“drop:%d\n“
“goalDiff:%d\n“
“points:%d\n“,
team-》name,team-》wins,
team-》draws,team-》losses,
team-》goal,team-》drop,
team-》goalDiff,team-》points
);
}
voidprintTeamList(constTeam*list)
{
constTeam*team=list;
intindex=1;
while(team!=NULL){
printf(“%d“,index);
printTeam(team);
team=team-》next;
index++;
}
}
voidstoreTeamInfo(
Team**list,
constchar*name,
intgoal,
intdrop
)
{
Team*team=findTeam(*list,name);
if(team!=NULL)
updateTeam(team,goal,drop);
else{
team=createTeam(name,goal,drop);
appendTeam(list,team);
}
}
voidparseTeamInfo(
constchar*matchResult,
char*aName,
int*goal,
int*drop,
char*bName
)
{
sscanf(matchResult,“%s%d:%d%s“,aName,goal,drop,bName);
}
intmain(void)
{
Team*teamList=NULL;
FILE*file;
charmatchResult;
file=fopen(“MatchResult.txt“,“r“);
if(file==NULL){
printf(“FailedtoopenthefileMatchResult.txt\n“);
return1;
}
//注意,仅支持文件一行不超过1024个字符
//同时,每一行的格式必须正确。
while(fgets(matchResult,1024,file)){
charaName;
intgoal,drop;
parseTeamInfo(matchResult,aName,&goal,&drop,bName);
storeTeamInfo(&teamList,aName,goal,drop);
storeTeamInfo(&teamList,bName,drop,goal);
}
fclose(file);
if(saveTeamList(teamList)){
printf(“Failedtosavetheteamlist!\n“);
return2;
}
teamList=NULL;
if(loadTeamList(&teamList)){
printf(“Failedtoloadtheteamlist!\n“);
return3;
}
printTeamList(teamList);
return0;
}
------------------------
MatchResult.txt文件格式:
Abc4:1Def
Def3:2hij
限制:球队名中间不能加空格。且球队名不长于256个字符。
如果球队名中间出现空格,可用“_”代替,或修改parseTeamInfo函数。
256是一个我直接使用的数字,可用宏替代之。
最后,我没有释放内存。
C语言 输入参加世界杯的32支球队,由计算机产生一份分组名单,每组4支球队
#include《time.h》
#include《stdio.h》
intfunc(inti)
{
clock_tt;
inth,s;
system(“pause“);
t=clock();
if(t》=1000000)
h=t%1000000%100000%10000%1000%100;
elseif(t》=100000)
h=t%100000%10000%1000%100;
elseif(t》=10000)
h=t%10000%1000%100;
elseif(t》=1000)
h=t%1000%100;
elseif(t》=100)
h=t%100;
elseif(t》=0)
h=t;
s=h*i/100;//0到i-1的随机数
returns;
}
intmain()
{
charteam;
inti,s;
for(i=0;i《32;i++)
scanf(“%s“,team);
for(i=0;i《32;i++)
p;
do
{
s=func(i);
{
printf(“%s“,p);
for(;s《i-1;s++)
p;
i--;
}
}
while(i》0);
getch();
return0;
}
你有其它答案了请告诉我。
求一段C语言程序,150-200行,什么都行,做课设用的万分感谢!!!!
============赛车游戏=====================
#include《math.h》
#include《conio.h》
#include《stdio.h》
#include《stdlib.h》
#include《graphics.h》
staticintc=1;
staticinte=0;
staticintu=0;
staticintv=0;
staticintx=1;
staticinty=0;
staticintj=-21;
staticinti;
staticintb;
voidbegin(void)
{
intxmax,ymax;
intstartx,starty,endx,endy;
setbkcolor(WHITE);
xmax=getmaxx();
ymax=getmaxy();
endx=20;endy=20;
startx=10;starty=10;
setcolor(RED);
settextstyle(1,HORIZ_DIR,4);
outtextxy(10,240,“BusBusBus“);
outtextxy(300,300,“MadebyPUBIN.“);
setlinestyle(SOLID_LINE,0,3);
setwritemode(XOR_PUT);
setcolor(GREEN);
while(startx《xmax&&starty《ymax)
{
rectangle(startx,starty,endx,endy);
delay(4);
rectangle(startx,starty,endx,endy);
startx+=2;
starty+=startx*startx/2000;
endx=startx+10;
endy=starty+10;
sound(startx*10);
delay(10);
nosound();
}
getch();
cleardevice();
}
voidroad(void)
{
inth;
for(h=0;h《4;h++)
line(150+h*100,0,150+h*100,472);
for(h=0;h《3;h++)
{
setlinestyle(3,0,1);
line(200+h*100,0,200+h*100,472);
settextstyle(1,HORIZ_DIR,3);
}
settextstyle(1,HORIZ_DIR,4);
setcolor(RED);
outtextxy(40,40,“PASS“);
outtextxy(40,80,“1“);
setcolor(10);
setlinestyle(SOLID_LINE,0,3);
rectangle(150,400,450,460);
outtextxy(160,410,“Ready,Begin!“);
}
voidmath(void)
{
settextstyle(1,HORIZ_DIR,4);
setcolor(RED);
if(x==2)
{
outtextxy(40,80,“1“);
outtextxy(40,80,“2“);
}
elseif(x==3)
{
outtextxy(40,80,“2“);
outtextxy(40,80,“3“);
}
elseif(x==4)
{
outtextxy(40,80,“3“);
outtextxy(40,80,“4“);
}elseif(x==5){
outtextxy(40,80,“4“);
outtextxy(40,80,“5“);
}elseif(x==6){
outtextxy(40,80,“5“);
outtextxy(40,80,“6“);
}elseif(x==7){
outtextxy(40,80,“6“);
outtextxy(40,80,“7“);
}elseif(x==8){
outtextxy(40,80,“7“);
outtextxy(40,80,“8“);
}elseif(x==9){
outtextxy(40,80,“8“);
outtextxy(40,80,“9“);
}elseif(x==10){
outtextxy(40,80,“9“);
outtextxy(40,80,“10“);
}elseif(x==11){
outtextxy(40,80,“10“);
outtextxy(40,80,“11“);
}elseif(x==12){
outtextxy(40,80,“11“);
outtextxy(40,80,“12“);
}elseif(x==13){
outtextxy(40,80,“12“);
outtextxy(40,80,“13“);
}elseif(x==14){
outtextxy(40,80,“13“);
outtextxy(40,80,“14“);
}elseif(x==15){
outtextxy(40,80,“14“);
outtextxy(40,80,“15“);
}elseif(x==16){
outtextxy(40,80,“15“);
outtextxy(40,80,“16“);
}elseif(x==17){
outtextxy(40,80,“16“);
outtextxy(40,80,“17“);
}elseif(x==18){
outtextxy(40,80,“17“);
outtextxy(40,80,“18“);
}elseif(x==19){
outtextxy(40,80,“18“);
outtextxy(40,80,“19“);
}elseif(x==20){
outtextxy(40,80,“19“);
outtextxy(40,80,“20“);
}elseif(x==21){
outtextxy(40,80,“20“);
outtextxy(40,80,“21“);
}elseif(x==22){
outtextxy(40,80,“21“);
outtextxy(40,80,“22“);
}elseif(x==23){
outtextxy(40,80,“22“);
outtextxy(40,80,“23“);
}elseif(x==24){
outtextxy(40,80,“23“);
outtextxy(40,80,“24“);
}elseif(x==25){
outtextxy(40,80,“24“);
outtextxy(40,80,“25“);
y=1;v=1;
}
}
voidbus2(void)
{
setcolor(BLUE);
rectangle(180+c*100,350,220+c*100,390);
rectangle(170+c*100,340,230+c*100,350);
rectangle(190+c*100,320,210+c*100,340);
rectangle(170+c*100,390,230+c*100,400);
setcolor(5);
line(190+c*100,350,190+c*100,390);
line(200+c*100,350,200+c*100,390);
line(210+c*100,350,210+c*100,390);
line(200+c*100,300,200+c*100,320);
line(185+c*100,300,215+c*100,300);
if((b==0x4b00)&&(c》0))
c--;
elseif((b==0x4d00)&&(c《2))
c++;
elseif((b==0x5000)&&(c《2))
sleep(1);
setcolor(BLUE);
rectangle(180+c*100,350,220+c*100,390);
rectangle(170+c*100,340,230+c*100,350);
rectangle(190+c*100,320,210+c*100,340);
rectangle(170+c*100,390,230+c*100,400);
setcolor(5);
line(190+c*100,350,190+c*100,390);
line(200+c*100,350,200+c*100,390);
line(210+c*100,350,210+c*100,390);
line(200+c*100,300,200+c*100,320);
line(185+c*100,300,215+c*100,300);
setcolor(BLUE);
}
voidlight(void)
{
rectangle(535,65,565,155);
floodfill(545,100,BLUE);
setfillstyle(1,RED);
fillellipse(550,80,10,10);
sound(650);
delay(300);
nosound();
delay(100);
setfillstyle(1,YELLOW);
fillellipse(550,110,10,10);
sound(650);
delay(300);
nosound();
delay(100);
setfillstyle(1,GREEN);
fillellipse(550,140,10,10);
sound(650);
delay(300);
nosound();
delay(100);
setcolor(10);
setlinestyle(SOLID_LINE,0,3);
rectangle(150,400,450,460);
outtextxy(160,410,“Ready,Begin!“);
}
voidbrock(void)
{
if((c==i)&&(j》4)&&(j《38))
e=1;
}
voidtree(void)
{
intw;
intpoly;
setcolor(10);
for(w=-3;w《3;w=w+2)
{
line(85,-25+u*15+w*157,85,35+u*15+w*157);
line(95,-25+u*15+w*157,95,35+u*15+w*157);
line(105,-25+u*15+w*157,105,35+u*15+w*157);
line(115,-25+u*15+w*157,115,35+u*15+w*157);
line(75,-9+u*15+w*157,75,19+u*15+w*157);
line(125,-9+u*15+w*157,125,19+u*15+w*157);
}
for(w=-2;w《3;w=w+2)
{
poly=530;
poly=u*15+w*157;
poly=515;
poly=25+u*15+w*157;
poly=485;
poly=25+u*15+w*157;
poly=470;
poly=u*15+w*157;
poly=485;
poly=-25+u*15+w*157;
poly=515;
poly=-25+u*15+w*157;
poly;
poly;
drawpoly(7,poly);
}
}
voidbus1(void)
{
randomize();
i=random(3);
setlinestyle(SOLID_LINE,0,3);
do
{
do
{
if((x!=7)&&(x!=16)&&(x!=23))
setcolor(x);
else
setcolor(2);
rectangle(170+i*100,j*10,230+i*100,60+j*10);
rectangle(160+i*100,70+j*10,240+i*100,260+j*10);
line(180+i*100,70+j*10,180+i*100,260+j*10);
line(200+i*100,70+j*10,200+i*100,260+j*10);
line(220+i*100,70+j*10,220+i*100,260+j*10);
tree();
sound(j*10);
delay(10);
nosound();
if((x!=7)&&(x!=16)&&(x!=23))
setcolor(x);
else
setcolor(2);
rectangle(170+i*100,j*10,230+i*100,60+j*10);
rectangle(160+i*100,70+j*10,240+i*100,260+j*10);
line(180+i*100,70+j*10,180+i*100,260+j*10);
line(200+i*100,70+j*10,200+i*100,260+j*10);
line(220+i*100,70+j*10,220+i*100,260+j*10);
tree();
u++;
j++;
brock();
if(e==1)
{
j=48;
y=1;
u=63;
v=0;
}
}while((bioskey(1)==0)&&(j《=47)&&(u《=62));
if((j《=47)&&(u《=62))
/*function0returnsthekeythatiswaiting*/
{
b=bioskey(0);
bus2();
}
elseif(u《=62)
{
j=-21;
randomize();
i=rand()%3;
x++;
math();
setcolor(x);
}
else
u=0;
}while(y!=1);
}
voidend()
{
if(v==1)
{
for(j=0;j《94;j++)
{
rectangle(150,j*5,450,60+j*5);
settextstyle(1,HORIZ_DIR,4);
outtextxy(160,10+j*5,“STOP!Youwin!“);
sound(500+j*10);
delay(2);
nosound();
setlinestyle(SOLID_LINE,0,3);
rectangle(150,j*5,450,60+j*5);
outtextxy(160,10+j*5,“STOP!Youwin!“);
}
closegraph();
printf(“\n\nyouwin!“);
}
elseif(v==0)
{
closegraph();
printf(“\n\nYoulose.“);
}
printf(“\n\n\nComebackagain.\n\nMadebyYOULIAOworkinghouse.pubingk@citiz.net“);
getch();
getch();
}
voidcar()
{
setcolor(BLUE);
setlinestyle(SOLID_LINE,0,3);
rectangle(280,350,320,390);
rectangle(270,340,330,350);
rectangle(290,320,310,340);
rectangle(270,390,330,400);
setcolor(5);
line(290,350,290,390);
line(300,300,300,320);
line(300,350,300,390);
line(310,350,310,390);
line(285,300,315,300);
setcolor(BLUE);
}
voidmain(void)
{
intgdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,““);
begin();
setbkcolor(7);
setcolor(WHITE);
setwritemode(XOR_PUT);
road();
car();
light();
bus1();
end();
}
===============活动赛车=============
#include《graphics.h》
staticintu=0;
staticintx=1;
staticintj=-21;
staticinti;
voidroad(void)
{
inth;
for(h=0;h《4;h++)
line(150+h*100.0,0,150+h*100,472);
for(h=0;h《3;h++)
{
setlinestyle(3,0,1);/*3是线形,1是线宽,中间的一般为0*/
line(200+h*100,0,200+h*100,472);
settextstyle(1,HORIZ_DIR,3);
}
}
voidtree(void)
{
intw;
intpoly;
setcolor(10);
for(w=-3;w《3;w=w+2)/*左边树木*/
{
line(85,-25+u*15+w*157,85,36+u*15+w*157);
line(95,-25+u*15+w*157,95,35+u*15+w*157);
line(105,-25+u*15+w*157,95,35+u*15+w*157);
line(115,-25+u*15+w*157,95,35+u*15+w*157);
line(75,-25+u*15+w*157,95,35+u*15+w*157);
line(125,-25+u*15+w*157,95,35+u*15+w*157);
}
for(w=-2;w《3;w=w+2)/*右边树木*/
{
poly=530;
poly=u*15+w*157;
poly=515;
poly=25+u*15+w*157;
poly=485;
poly=25+u*15+w*157;
poly=470;
poly=u*15+w*157;
poly=485;
poly=-25+u*15+w*157;
poly=515;
poly=-25+u*15+w*157;
poly;
poly;
drawpoly(7,poly);
}
}
voidbus1(void)
{
i=2;
setlinestyle(SOLID_LINE,0,3);
do
{
if((x!=7)&&(x!=16)&&(x!=23))
setcolor(x);
elsesetcolor(2);
/*绘制卡车*/
rectangle(170+i*100,j*10,230+i*100,60+j*10);
rectangle(160+i*100,70+j*10,240+i*100,260+j*10);
line(180+i*100,70+j*10,180+i*100,260+j*10);
line(200+i*100,70+j*10,200+i*100,260+j*10);
line(220+i*100,70+j*10,220+i*100,260+j*10);
tree();
delay(3500);
if((x!=7)&&(x!=16)&&(x!=23))
setcolor(x);
elsesetcolor(2);
/*擦除车*/
rectangle(170+i*100,j*10,230+i*100,60+j*10);
rectangle(160+i*100,70+j*10,240+i*100,260+j*10);
line(180+i*100,70+j*10,180+i*100,260+j*10);
line(200+i*100,70+j*10,200+i*100,260+j*10);
line(220+i*100,70+j*10,220+i*100,260+j*10);
tree();
u++;/*树木卡车位置偏移*/
j++;
}
while((j《=47)&&(u《=62));
}
voidcar(void)
{
setcolor(BLUE);
setlinestyle(SOLID_LINE,0,3);
rectangle(280,350,320,390);
rectangle(270,340,330,350);
rectangle(290,320,310,340);
rectangle(270,390,330,400);
setcolor(5);
line(290,350,290,390);
line(300,300,300,320);
line(300,350,300,390);
line(310,350,310,390);
line(285,300,315,300);
setcolor(BLUE);
}
intmain(void)
{
intgdriver=DETECT,gmode;
/*初始化图形模式和逻辑变量*/
initgraph(&gdriver,&gmode,““);
setbkcolor(7);
setcolor(WHITE);
setwritemode(XOR_PUT);/*设置异或模式*/
getch();
road();
car();
bus1();
getch();
closegraph();
return0;
}
turboc运行
C语言课程设计不少于200行代码
#include“stdio.h“
#include“stdlib.h“
#include“conio.h“
#include“string.h“
structSStudent
{
unsignednumber;
charname;
chartele;
structSStudent*link;
};
voidmain()
{
structSStudent*CreateTable();
voidAppendToTable(structSStudent*stu);
voidInsertToTable(structSStudent*stu);
voidQueryTable(structSStudent*stu,unsignednumber);
voidSortTable(structSStudent*stu);
voidPrintTable(structSStudent*stu);
voidSave(structSStudent*stu);
voidLoad(structSStudent*stu);
voidHelp();
voidmodi(structSStudent*h);
voidsearch(structSStudent*h);structSStudent*student;
unsignednumber;
charkeyValue;
student=CreateTable();
//clrscr();
system(“cls“);
Help();
printf(“\n=“);
while((keyValue=getche())!=’q’&&keyValue!=’Q’&&keyValue!=27)
{
puts(““);
switch(keyValue)
{
case’l’:case’L’:
PrintTable(student);break;
case’d’:case’D’:
printf(“Pleaseinputthenumberyouwantdelete:“);
scanf(“%d“,&number);
QueryTable(student,number);
break;
case’a’:case’A’:
AppendToTable(student);break;
case’i’:case’I’:
InsertToTable(student);break;
case’s’:case’S’:
SortTable(student);
puts(“Sortcomplished!PleaseusecommandLtolist.“);
break;
case’f’:case’F’:
search(student);
break;
case’m’:case’M’:
modi(student);
break;case’v’:case’V’:
Save(student);break;
case’o’:case’O’:
Load(student);break;
case’h’:case’H’:
Help();break;
default:puts(“Errorcommand!“);
}
printf(“\n=“);
}
}
structSStudent*CreateTable()
{
structSStudent*stu;
stu=(structSStudent*)malloc(sizeof(structSStudent));
stu-》number=0;
stu-》name=’\0’;
stu-》tele=’\0’;
stu-》link=NULL;
return(stu);
}
voidAppendToTable(structSStudent*stu)
{
structSStudent*next,*last;
intnumber;
last=stu;
while(last-》link)last=last-》link;
printf(“Pleaseinputthenumber(0toquit):“);
scanf(“%d“,&number);
while(number)
{
next=(structSStudent*)malloc(sizeof(structSStudent));
next-》number=number;
printf(“Pleaseinputname:“);
scanf(“%s“,next-》name);
printf(“Pleaseinputtele:“);
scanf(“%s“,next-》tele);
last-》link=next;
last=last-》link;
printf(“\nPleaseinputthenumber(0toquit):“);
scanf(“%d“,&number);
}
last-》link=NULL;
}
voidInsertToTable(structSStudent*stu)
{
structSStudent*next,*last;
intnumber;
printf(“Pleaseinputthenumber(0toquit):“);
scanf(“%d“,&number);
while(number)
{
next=(structSStudent*)malloc(sizeof(structSStudent));
next-》number=number;
printf(“Pleaseinputname:“);
scanf(“%s“,next-》name);
printf(“Pleaseinputtele:“);
scanf(“%s“,next-》tele);
last=stu;
while(last-》link)
{
if(last-》link-》number》next-》number)
{
next-》link=last-》link;
last-》link=next;
break;
}
elselast=last-》link;
}
printf(“\nPleaseinputthenumber(0toquit):“);
scanf(“%d“,&number);
}
}
voidQueryTable(structSStudent*stu,unsignednumber)
{
structSStudent*temp,*next;
next=stu;
while(next-》link)
{
if(next-》link-》number==number)
{
temp=next-》link;
next-》link=next-》link-》link;
free(temp);
}
elsenext=next-》link;
}
}
voidPrintTable(structSStudent*stu)
{
stu=stu-》link;
if(!stu)
{
puts(“ThetableisEMPTY!“);
return;
}
printf(“number\tname\ttele\n“);
while(stu)
{
printf(“%3d\t“,stu-》number);
printf(“%-s\t“,stu-》name);
printf(“%-s\t“,stu-》tele);
printf(“\n“);
stu=stu-》link;
}
}
voidSortTable(structSStudent*stu)
{
structSStudent*next,*last,*temp;
intflag;
last=stu;
while(last-》link)
{
next=stu;flag=1;
while(next-》link!=last-》link)
{
if(next-》link-》number》last-》link-》number)
{
temp=last-》link;
last-》link=last-》link-》link;
temp-》link=next-》link;
next-》link=temp;
flag=0;
break;
}
elsenext=next-》link;
}
if(flag)last=last-》link;
}
}
voidSave(structSStudent*stu)
{
charfilename;
FILE*fileSave;
printf(“Pleaseinputthefilenameyouwantsavein:“);
scanf(“%s“,filename);
if((fileSave=fopen(filename,“wb“))==0)
{
printf(“Cannotopenfile%s!\n“,filename);
return;
}
puts(“Saveing...“);
stu=stu-》link;
while(stu)
{
fwrite(stu,sizeof(structSStudent),1,fileSave);
stu=stu-》link;
}
puts(“Saveingisfinished!“);
}
voidLoad(structSStudent*stu)
{charfilename;《br》FILE*fileLoad;《br》structSStudent*temp;《br》while(stu-》link)《br》{《br》temp=stu-》link;《br》stu-》link=stu-》link-》link;《br》free(temp);《br》}
temp=(structSStudent*)malloc(sizeof(structSStudent));
printf(“Pleaseinputthefilenameyouwantloadfrom:“);
scanf(“%s“,filename);
if((fileLoad=fopen(filename,“rb“))==0)
{
printf(“Cannotopenfile%s!\n“,filename);
return;
}
puts(“Loading...“);
while(fread(temp,sizeof(structSStudent),1,fileLoad))
{stu-》link=temp;《br》stu=stu-》link;《br》temp=(structSStudent*)malloc(sizeof(structSStudent));《br》}
stu-》link=NULL;
puts(“loadingisfinished!“);
}
voidHelp()
{puts(“*********************************************“);
puts(“*SystemCommandHelp*“);
puts(“*********************************************“);
puts(“*L=Listallrecords*“);
puts(“*D=Deletearecordselecedbynumber*“);
puts(“*A=Appendrecords*“);
puts(“*I=Insertrecords*“);
puts(“*S=Sortrecords*“);
puts(“*F=Searchrecords*“);
puts(“*M=Modirecords*“);puts(“*H=Showthishelpmessage*“);
puts(“*V=Saverecordstoafile*“);
puts(“*O=Loadrecordsfromafile*“);
puts(“*Q=QuitSystem*“);
puts(“*********************************************“);
}
voidmodi(structSStudent*h)
{
structSStudent*p;/*移动指针*/
unsignednum;/*存放学号的变量*/
//clrscr();/*清屏幕*/
system(“cls“);
printf(“pleaseenternumberformodifi\n“);
scanf(“%d“,#);/*输入学号*/
p=h;/*将头指针赋给p*/
while((p-》number!=num)&&p!=NULL)/*当记录的姓名不是要找的,且指针不为空时*/
p=p-》link;/*移动指针,指向下一结点*/
if(p==NULL)/*如果指针为空*/
printf(“\nlistno%dstudent\n“,num);/*显示没有该学生*/
else/*修改找到的记录信息*/
{
printf(“Pleaseinputnewname:“);
scanf(“%s“,p-》name);
printf(“Pleaseinputnewtele:“);
scanf(“%s“,p-》tele);
printf(“|number|name|tel|\n“);
printf(“|----------|---------------|---------------|\n“);
printf(“|%6d|%-10s|%12s|\n“,p-》number,p-》name,p-》tele);}
}
voidsearch(structSStudent*h)
{
structSStudent*p;/*移动指针*/
chars;/*存放姓名的字符数组*/
//clrscr();/*清屏幕*/
system(“cls“);
printf(“pleaseenternameforsearch\n“);
scanf(“%s“,s);/*输入姓名*/
p=h;/*将头指针赋给p*/
while(strcmp(p-》name,s)&&p!=NULL)/*当记录的姓名不是要找的,且指针不为空时*/
p=p-》link;/*移动指针,指向下一结点*/
if(p==NULL)/*如果指针为空*/
printf(“\nlistno%sstudent\n“,s);/*显示没有该学生*/
else/*显示找到的记录信息*/
{
printf(“\n\n***********************havefound***********************\n“);
printf(“|number|name|tel|\n“);
printf(“|----------|---------------|---------------|\n“);
printf(“|%10d|%-10s|%12s|\n“,p-》number,p-》name,p-》tele);
printf(“****************************end***************************\n“);
}
}
如果您对本文的解答感到满意,请在文章结尾处点击“顶一下”以表示您的肯定。如果您对本文不满意,也请点击“踩一下”,以便我们改进该篇文章。