C语言实验八

上传人:汽*** 文档编号:557302410 上传时间:2023-09-18 格式:DOC 页数:3 大小:19KB
返回 下载 相关 举报
C语言实验八_第1页
第1页 / 共3页
C语言实验八_第2页
第2页 / 共3页
C语言实验八_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《C语言实验八》由会员分享,可在线阅读,更多相关《C语言实验八(3页珍藏版)》请在金锄头文库上搜索。

1、实验结束将答案发至, 标题取学号姓名第八次实验1编程题 p84问题描述 字符串复制。输入一个字符串t和一个正整数m,将字符串t中从第m个字符开始的全部字符复制到字符串s中,再输出字符串s。要求用字符指针定义并调用函数strmcpy(s,t,m),它的功能是将字符串t中从第m个字符开始的全部字符复制到字符串s中。void strmcpy(char *s, char *t, int n)输入:Input a string:happy new yearInput an integer:7输出:Output is:new year#include#includeint main()void strmc

2、py(char *s,char *t,int m); int m; char t80, s80; gets(t); scanf(%d,&m); if(strlen(t)m) printf(error input!n); else strmcpy(s,t,m); printf(%sn,s); Void strmcpy(char *s,char *t,int m) char *from; char *to; from=t+m-1; to=s; do *to=*from; from+; to+; while(*(from-1)!=0); 2通讯录排序 p89【问题描述】建立一个通讯录的结构记录,包括

3、姓名(name)、生日(day)、电话号码(num)。输入n(n10)个朋友的信息,再按他们的年龄从大到小的顺序依次输出其信息【输入形式】先输入朋友数n(整型,n10),再依次输入每个朋友的姓名(字符串)、生日(long)、和电话号码(字符串)。【输入输出样例】(下划线部分表示输入)Input n:3Input the name, day,num of the 1 friend:zhang 19850403 Input the name, day,num of the 2 friend:wang 19821020 Input the name, day,num of the 3 friend:

4、qian 19840619 wang19821020qian19840619zhang19850403#includeint main() int i,j,n,index; struct friend char name20; long birthday; char phone20; temp, friends10; scanf(%d,&n); for(i=0;in;i+) scanf(%s%ld%s, friendsi.name, &friendsi.birthday, friendsi.phone); for(i=0;in;i+) index=i; for(j=i+1;jfriendsj.birthday) index=j; temp=friendsindex; friendsindex=friendsi; friendsi=temp; for(i=0;in;i+) printf(%s %ld %sn, friendsi.name,friendsi.birthday,friendsi.phone);3 构建简单的手机通讯录(用文件) 联系人的基本信息:姓名、年龄和联系电话 最多容纳50名联系人的信息 具有新建(f1.txt)、查询(f2.txt)功能void new_friend(void ); void search_friend(char *name);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 高等教育 > 研究生课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号