- 17
- 0
- 约16.48万字
- 约 35页
- 2019-01-10 发布于安徽
- 举报
. . WORD.格式整理. .
. .专业.知识.分享. .
1、将一个字符串逆序 2、将一个链表逆序 3、计算一个字节里(byte)里面有多少bit被置1 4、搜索给定的字节(byte) 5、在一个字符串中找到可能的最长的子字符串 6、字符串转换为整数 7、整数转换为字符串
/** 题目:将一个字符串逆序* 完成时间:2006.9.30深圳极讯网吧* 版权归刘志强所有* 描述:写本程序的目的是希望练一下手,希望下午去面试能成功,不希望国庆节之后再去找工作拉!*/#include iostreamusing namespace std;//#define NULL ((void *)0)char * mystrrev(char * const dest,const char * const src){if (dest==NULL src==NULL)?? return NULL;
char *addr = dest;int val_len = strlen(src);dest[val_len] = \0;int i;for (i=0; ival_len; i++){?? *(dest+i) = *(src+val_len-i-1);??}return addr;}main(){char *str=asdfa;char *str1=NULL;str1 = (char *)malloc(20);if (str1 == NULL)?? coutmalloc failed;coutmystrrev(str1,str);free(str1);str1=NULL;//杜绝野指针}
p=head; q=p-next; while(q!=NULL) { temp=q-next; q-next=p; p=q; q=temp; } 这样增加个辅助的指针就行乐。
ok 通过编译的代码: #include stdio.h #include ctype.h #include stdlib.h typedef struct List{ int data; struct List *next; }List; List *list_create(void) { struct List *head,*tail,*p; int e; head=(List *)malloc(sizeof(List)); tail=head; printf(\nList Create,input numbers(end of 0):); scanf(%d,e); while(e){ p=(List *)malloc(sizeof(List)); p-data=e; tail-next=p; tail=p; scanf(%d,e);} tail-next=NULL; return head; } List *list_reverse(List *head) { List *p,*q,*r; p=head; q=p-next; while(q!=NULL) { r=q-next; q-next=p; p=q; q=r; } head-next=NULL; head=p; return head; } void main(void) { struct List *head,*p; int d; head=list_create(); printf(\n); for(p=head-next;p;p=p-next) printf(--%d--,p-data); head=list_reverse(head); printf(\n); for(p=head;p-next;p=p-next) printf(--%d--,p-data); }
?????? 编写函数数N个BYTE的数据中有多少位是1。解:此题按步骤解:先定位到某一个BYTE数据;再计算其中有多少个1。叠加得解。#incluedeiostream#define N 10//定义BYTE类型别名#ifndef BYTEtypedef unsigned char BYTE;#endifint comb(BYTE b[],int n){int count=0;int bi,bj;BYTE cc=1,tt;/
您可能关注的文档
- 公交车事故逃生手册须知.doc
- 关键环节、重点部门岗位安全管理标准及措施.doc
- 关于创建二级甲等保健院工作进展汇报.doc
- 关于施工进度滞后因素情况报告.doc
- 管理数量方法及分析简答题.doc
- 国有企业党建工作流程图.doc
- 航空航天概论习题和试题库.doc
- 化学计量在实验中的应用.doc
- 会计制度设计第四次形考作业.doc
- 会计制度设计论文终稿.doc
- 七年级语文上册期末模拟试卷1(解析版).docx
- 七年级语文上册期末模拟试卷1(原卷版).docx
- 七年级语文上册期末模拟试卷2(原卷版).docx
- 七年级语文上册期末模拟试卷2(解析版).docx
- 期末测试卷(二)(解析版)2024—2025学年七年级语文上册期末测试卷(全国版).docx
- 期末测试卷(三)(解析版)2024—2025学年七年级语文上册期末测试卷(全国版).docx
- 期末测试卷(二)(原卷版)2024—2025学年七年级语文上册期末测试卷(全国版).docx
- 期末测试卷(三)(原卷版)2024—2025学年七年级语文上册期末测试卷(全国版).docx
- 期末测试卷(一)(原卷版)2024—2025学年七年级语文上册期末测试卷(全国版).docx
- 期末测试卷(一)(解析版)2024—2025学年七年级语文上册期末测试卷(全国版).docx
原创力文档

文档评论(0)