C:指针习题】的更多相关文章

1. 请指出以下程序段中的错误. 程序中的错误有:(1)p=i:类型不匹配.(2)q=*p:q 是指针,*p 是指针 p 指向变量的值.(3)t='b':t 是指针类型. 解释:指针变量是一种存放地址的特殊变量,其特殊性表现在类型和值上.指针变量的类型是指针变量所指向的变量的类型,而不是自身的类型.指针变量赋值应该是地址值. 正确程序应为:main (){ int i,j,*p,*q; char ch1,ch2,*t,*s; i=3; p=&i; j=*p/2+10; q=p; ch1='a';…
 J:\传智播客_尹成_C语言从菜鸟到高手├─传智播客_尹成_C语言从菜鸟到高手_第一章C语言概述A│      第一讲1.1C语言第一阶段.mp4│      第二讲1.2c语言入门教程.mp4│      ├─传智播客_尹成_C语言从菜鸟到高手_第七章编译选项_链表_栈_队列_C实战│  ├─7.1编译与预处理│  │      第10讲 7.1.14-24宏的高级用法2.mp4│  │      第11讲 7.1.25文件包含-7.1.28编译及预处理小节.mp4│  │      第…
17.8 为数组形式的树编写模块,用于从树中删除一个值,如果没有找到,程序节点 ArrayBinaryTree.c // // Created by mao on 16-9-18. // #include "ArrayBinaryTree.h" #include <assert.h> #include <stdio.h> unsigned long leftChild(unsigned long current) { return 2 * current; }…
1,1标准输入读入字符,统计各类字符所占百分比 #include <stdio.h> #include <ctype.h> //不可打印字符 int isunprint(int ch){ return !isprint(ch); } //转换表,储存各个判断函数指针 int (*tables[])(int) = {iscntrl, isspace, isdigit, islower, isupper, ispunct, isunprint}; int main() { int co…
12.3 重新编写12.7,使用头和尾指针分别以一个单独的指针传递给函数,而不是作为一个节点的一部分 #include <stdio.h> #include <stdlib.h> #define TRUE 1 #define FALSE 0 //指针fwd指向前一个节点,bwd指向后一个节点 typedef struct NODE { struct NODE *fwd; struct NODE *bwd; int value; } Node; /*传入指向 头部和尾部节点的指针 的…
1编写calloc,内部使用malloc函数获取内存 #include <stdio.h> #include <stdlib.h> void *myAlloc(unsigned long int length, unsigned long int typeSize) { int *ptr; int index = 0; int totalLen = length * typeSize; if(length >= 0 && typeSize >= 0){…
9.15 编写函数格式化金钱为标准字符串 #include <stdio.h> #include <string.h> #define TEMP_LEN 1000 void dollars(char *dest, char const * src) { int len; int num; //当长度大于二,第一个逗号之前的字数 int headerLen; //当前复制的位置 int loc; len = strlen(src); char *dstTmp = dest; if (…
7.1 hermite递归函数 int hermite(int n, int x) { if (n <= 0) { return 1; } if (n == 1) { return 2 * x; } return 2 * x * hermite(n - 1, x) - 2 * (n - 1) * hermite(n - 2, x); } 7.2两个整型值M和N(m.n均大于0)的最大公约数计算公式: gcd(M,N) 当M % N = 0;  N 当M % N =R, R > 0; gcd(N…
6.1编写一个函数,它在一个字符串中进行搜索,查找所有在一个给定字符集中出现的字符,返回第一个找到的字符位置指针,未找到返回NULL #include <stdio.h> char * find_char(char const *source, char const *chars) { char const *sptr = source; char const *cptr = chars; if (sptr == NULL || cptr == NULL) { return NULL; } w…
16.8 计算平均年龄 #include <stdlib.h> #include <stdio.h> #define MAX_LEN 512 int main() { int age; int totalAge; float avgAge; int peopleNum; FILE *file; char info[MAX_LEN]; char *infoPtr; file = fopen("D:/family.txt", "r"); //按行…