一道C语言题目,求高手解决! 100
题目:将B_树的结点类型中key[m+1]和recptr[m+1]分别改为key[m]和recptr[m],并使用0号单元,据此修改程序大虾帮忙!急用!非常感谢。。。主程...
题目:将B_树的结点类型中key[m+1]和recptr[m+1]分别改为key[m]和recptr[m],并使用0号单元,据此修改程序 大虾帮忙!
急用!非常感谢。。。
主程序是algo8-6.cpp,好像要改的在c8-5.cpp和bo8-4.cpp里面。
相关程序下载:http://pickup.mofile.com/7409852475827449
请先留言,再将该后程序打包传给我,我的邮箱:ak47nfj@163.com
如有帮助,会追加给分,谢谢了!
说了过后会补分的,明天也行,谢谢了 展开
急用!非常感谢。。。
主程序是algo8-6.cpp,好像要改的在c8-5.cpp和bo8-4.cpp里面。
相关程序下载:http://pickup.mofile.com/7409852475827449
请先留言,再将该后程序打包传给我,我的邮箱:ak47nfj@163.com
如有帮助,会追加给分,谢谢了!
说了过后会补分的,明天也行,谢谢了 展开
4个回答
展开全部
晕, 大半夜的, 着急才给了50分, 谁会帮你做啊, 不急的话 明天吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
抱歉无能为力 等有人解决告诉我下 我学学 嘿嘿
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
给200分,我给你做!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
下面转一个参考:
int ftpcmd(int sockftp,char *fmt,...) //cmd
{
va_list vp;
int err,len;
int i,j,n,p;
if (ftpio == NULL)
{
ftpio = fdopen(sockftp,"r"); //socket->file pointer
if (ftpio == NULL)
return -1;
}
if (fmt)
{
va_start(vp,fmt);
len = vsprintf(ftp_buf,fmt,vp);
ftp_buf[len++] = '\r';
ftp_buf[len++]='\n';
write(sockftp,ftp_buf,len); //buf->socket
}
n=read(sockftp,ftp_buffer,sizeof(ftp_buffer));
printf("the buff is %s\n",ftp_buffer);
if(fmt=="PASV") //被动模式下提取需要连接服务端的端口
{
ftp_buffer[n-3]='\0';
str1=ftp_buffer+39;
str2=strchr(str1,',');
i=atoi(str2+1);
n=0;
while(str1[n]!=',')
{
str3[n]=str1[n];
n++;
}
j=atoi(str3);
p=j*256+i;
return p;
}
return 1;
}
int ftp()
{
char *host="ftp.tust.edu.cn";
char *user="ejia";
char *pass="ejia2094ejia";
char *filename="net";
char *savefile="net";
int sockftp = -1,sockdata = -1,sockxfer = -1;
struct sockaddr_in addr;
unsigned long hostip;
int len,tmp,err,err1;
int retval = -1;
int savefd;
char *del=":";
char *port;
struct hostent *he;
hostip = inet_addr(host); //ip
sockftp = socket(AF_INET,SOCK_STREAM,0); //control socket
if (sockftp == -1)
goto out;
addr.sin_family = PF_INET;
addr.sin_port = htons(21);
addr.sin_addr.s_addr = hostip;
if (connect(sockftp,(struct sockaddr *)&addr,sizeof(addr)) == -1) //wait for connect
goto out;
err = ftpcmd(sockftp,NULL); //connect ftp server
err = ftpcmd(sockftp,"USER %s",user);
err = ftpcmd(sockftp,"PASS %s",pass);
err = ftpcmd(sockftp,"TYPE I");
err1 = ftpcmd(sockftp,"PASV");
tmp = sizeof(addr);
sockdata = socket(AF_INET,SOCK_STREAM,0); //data socket
if (sockdata == -1)
goto out;
memset(&addr,0,tmp);
addr.sin_family = AF_INET;
addr.sin_port = htons(err1);
addr.sin_addr.s_addr = inet_addr(host);;
sockxfer = connect(sockdata,&addr,tmp);
if (sockxfer == -1)
goto out;
err=ftpcmd(sockftp,"RETR %s",filename);
/*savefd = open(savefile,O_RDWR | O_CREAT); //create file
if (savefd == -1)
goto out; */
len=read(sockdata,ftp_buf,sizeof(ftp_buf));
client_ip=strtok(ftp_buf,del);
port=strtok(NULL,del);
client_port=atoi(port);
printf("the cilentip is %s,the port is %d\n",client_ip,client_port);
/*write(savefd,ftp_buf,len);
close(savefd);*/
out:
close(sockxfer);
close(sockdata);
close(sockftp);
}
注意一下包含库文件
<sys/un.h>
<netinet/in.h>
<sys/socket.h>
<netdb.h>
<arpa/inet.h>
当然还有<unistd.h>
介绍本书《高级UNIX编程》外文翻译的,
里面讲得很详细。
int ftpcmd(int sockftp,char *fmt,...) //cmd
{
va_list vp;
int err,len;
int i,j,n,p;
if (ftpio == NULL)
{
ftpio = fdopen(sockftp,"r"); //socket->file pointer
if (ftpio == NULL)
return -1;
}
if (fmt)
{
va_start(vp,fmt);
len = vsprintf(ftp_buf,fmt,vp);
ftp_buf[len++] = '\r';
ftp_buf[len++]='\n';
write(sockftp,ftp_buf,len); //buf->socket
}
n=read(sockftp,ftp_buffer,sizeof(ftp_buffer));
printf("the buff is %s\n",ftp_buffer);
if(fmt=="PASV") //被动模式下提取需要连接服务端的端口
{
ftp_buffer[n-3]='\0';
str1=ftp_buffer+39;
str2=strchr(str1,',');
i=atoi(str2+1);
n=0;
while(str1[n]!=',')
{
str3[n]=str1[n];
n++;
}
j=atoi(str3);
p=j*256+i;
return p;
}
return 1;
}
int ftp()
{
char *host="ftp.tust.edu.cn";
char *user="ejia";
char *pass="ejia2094ejia";
char *filename="net";
char *savefile="net";
int sockftp = -1,sockdata = -1,sockxfer = -1;
struct sockaddr_in addr;
unsigned long hostip;
int len,tmp,err,err1;
int retval = -1;
int savefd;
char *del=":";
char *port;
struct hostent *he;
hostip = inet_addr(host); //ip
sockftp = socket(AF_INET,SOCK_STREAM,0); //control socket
if (sockftp == -1)
goto out;
addr.sin_family = PF_INET;
addr.sin_port = htons(21);
addr.sin_addr.s_addr = hostip;
if (connect(sockftp,(struct sockaddr *)&addr,sizeof(addr)) == -1) //wait for connect
goto out;
err = ftpcmd(sockftp,NULL); //connect ftp server
err = ftpcmd(sockftp,"USER %s",user);
err = ftpcmd(sockftp,"PASS %s",pass);
err = ftpcmd(sockftp,"TYPE I");
err1 = ftpcmd(sockftp,"PASV");
tmp = sizeof(addr);
sockdata = socket(AF_INET,SOCK_STREAM,0); //data socket
if (sockdata == -1)
goto out;
memset(&addr,0,tmp);
addr.sin_family = AF_INET;
addr.sin_port = htons(err1);
addr.sin_addr.s_addr = inet_addr(host);;
sockxfer = connect(sockdata,&addr,tmp);
if (sockxfer == -1)
goto out;
err=ftpcmd(sockftp,"RETR %s",filename);
/*savefd = open(savefile,O_RDWR | O_CREAT); //create file
if (savefd == -1)
goto out; */
len=read(sockdata,ftp_buf,sizeof(ftp_buf));
client_ip=strtok(ftp_buf,del);
port=strtok(NULL,del);
client_port=atoi(port);
printf("the cilentip is %s,the port is %d\n",client_ip,client_port);
/*write(savefd,ftp_buf,len);
close(savefd);*/
out:
close(sockxfer);
close(sockdata);
close(sockftp);
}
注意一下包含库文件
<sys/un.h>
<netinet/in.h>
<sys/socket.h>
<netdb.h>
<arpa/inet.h>
当然还有<unistd.h>
介绍本书《高级UNIX编程》外文翻译的,
里面讲得很详细。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询