已阅读5页,还剩7页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
.C Practice Print 9*9 multiplication table 1*1=1 1*2=2 2*2=4 1*3=3 2*3=6 3*3=9 1*4=4,2*4=8,3*4=12 4*4=16 1*9=9,. 9*9=81#include int main(void) int x,y,z; for(x=1;x=9;x+) for(y=1;y=x;y+) z=x*y; printf(%d*%d=%d,y,x,z); printf(n); Calculate 1+2!+3!+20!#includeintmain()inti;longlongsum=0,jc=1;for(i=1;i=20;+i)jc*=i;sum+=jc;printf(%dn,sum);return0;Input x and print y Y=2X,X0;Y=4X-2,0=X=10#include int main()float x,y;printf(Please input X:);scanf(%f,&x);if(x0)y=2*x;else if(x10)y=4*x-2;elsey=6*x*(x+3);printf(Y=%fn,y);Input a string from keyboard, write a program to calculate the number of alpha, digit space and other character.#includeint main()char str100;int i=0;int num=0,ch=0,blank=0,other=0;gets(str);while(stri!=0) if(stri=A & stri=a & stri=0 & stri=9) num+; else if(stri= ) blank+; else other+;i+; printf(数字%d个,字母%d个,空格%d个,其他%d个n,num,ch,blank,other); return 0;Read 5 integer from keyboard to sort in descending order#includeint main()int a5=0;int i,j,t;printf(请依次输入5个整数n);for(i=0;i5;i+) /输入5个数 scanf(%d,&ai);for(i=0;i5;i+) /从大到小排序 for(j=i+1;j5;j+) if(aiaj) t=ai; ai=aj; aj=t; for(i=0;i2), write a function to generate and print first n Fibonacci numbers.#include #include int main() int a=1,b=1,sum; int n,i; scanf(%d,&n); printf(%dn%dn,a,b); for (i=3;i=n;) sum=a+b; b=a; a=sum; if(i%1=0)printf(%dn,sum); i+; return 0; Write a program to produce the alphabet set A to Z and then saved it into a file. #include#includeint main()FILE *fp;char ch, filename10;printf(输入文件名:n);scanf(%s, filename);if (fp = fopen(filename, w) = NULL)printf(errorn);exit(0);for (ch = A; ch = A&ch = Z; ch+)fputc(ch, fp);putchar(ch);fclose(fp);putchar(10);return 0;Read a series of character from keyboard and write it to file, read file again to display it on screen.#include#includeint main()FILE *fp;char ch, filename10;printf(输入文件名:n);scanf(%s, filename);if (fp = fopen(filename, w) = NULL)printf(errorn);exit(0);ch = getchar();printf(输入一行字符回车结束:n);while(ch=getchar()!=n)fputc(ch, fp);putchar(ch);fclose(fp);putchar(10);printf(输入文件名:n);scanf(%s, filename);if (fp = fopen(filename, r) = NULL)printf(errorn);exit(0);char a;if (fp = fopen(filename, r) = NULL)printf(errorn);exit(0);while (!feof(fp)a = fgetc(fp);putchar(a);fclose(fp);return 0;Input one string from keyboard and use pointer to calculate to length of string #include#includeint main()char a20;char *p=a;scanf(%s, a);int i=0;while (*p != 0)p+;i+;printf(%dn, i);return 0;Give one strings and use pointer to copy this string to another.#includeint main()char a20, b20;char *from=a, *to=b;scanf(%s, a);for(;*from != 0;)*to = *from;from+, to+;*to = 0;printf(%s, b);return 0; Write 1 to 20 to a file, read it and put the sum of these number at the end of file.#include#includeint main()FILE *f;int b20, j, sum = 0;for (j = 0; j 20; j+)bj = j + 1;sum = sum + bj;char a10;printf(输入文件名:n);scanf(%s, a);if (f = fopen(a, w) = NULL)printf(error);exit(0);for (j = 0; j 20; j+)fprintf(f, %d , bj);fprintf(f, %d, sum);fclose(f);return 0; Use malloc() function to allocate 10 int units to 10 numbers and print it from 6th number using pointer. #include#include#define len sizeof(int)int main()int *p10;int a10, i;for (i = 0; i 10; i+)scanf(%d, &ai);for (i = 0; i 10; i+)pi = (int *)malloc(len);*pi = ai;for (i = 5; i 10; i+)printf(%d , *pi);return 0; Write a function with two integer number arguments and two pointer arguments to calculate two number sum and difference, return the sum and difference with two pointers to calling function.#includeint main()int f(int *p1, int *p2);int g(int *p1, int *p2);int a, b;int *p1, *p2;p1 = &a, p2 = &b;scanf(%d %d, &a, &b);printf(%dn%d, f(p1, p2), g(p1, p2);return 0;int f(int *p1, int *p2)int sum;sum = *p1 + *p2;return sum;int g(int *p1, int *p2)int dif;dif = *p1 - *p2;return dif;Using pointer to read an array of integer and print its elements in reverse order#include int main() int n, c, d, a100, b100; printf(Enter the number of elements in arrayn); scanf(%d, &n); printf(Enter the array elementsn); for (c = 0; c = 0; c-, d+) bd = ac; for (c = 0; c n; c+) ac = bc; printf(Reverse array isn); for (c = 0; c n; c+) printf(%dn, ac); return 0;运算符与表达式: 1.constant 常量 2. variable 变量 3. identify 标识符 4. keywords 关键字 5. sign 符号 6. operator 运算符 7. statement语句 8. syntax 语法 9. expression 表达式 10. initialition 初始化 11. number format 数据格式 12 declaration 说明 13. type conversion 类型转换 14.define 、definition 定义 条件语句: 1.select 选择 2. expression 表达式 3. logical expression 逻辑表达式 4. Relational expression 关系表达式 5.priority优先 6. operation运算 7.structure 结构 循环语句: 1.circle 循环 2. condition 条件 3. variant 变量 4. process过程 5.priority优先 6. operation运算 数组: 1. array 数组 2. reference 引用 3. element 元素 4. address 地址 5. sort 排序 6. character 字符 7. string 字符串 8. application 应用 函数: 1.call 调用 2.return value 返回值 3.function 函数 4. declare 声明 5. parameter 参数 6.static 静态的 7.extern 外部的 指针: 1. pointer 指针 2. argument 参数 3. array 数组 4. declaration 声明 5. represent 表示 6. manipulate 处理 结构体、共用体、链表: 1 structure 结构 2 member成员 3 tag 标记 4 function 函数 5 enumerate 枚举 6 union 联合(共用体) 7 create 创建 8 insert 插入 9 delete 删除 10 modify 修改 文件: 1、file 文件 2、open 打开 3、close 关闭 4、read 读 5、write 写 6、error 错误 序号 主要章节 常用英汉对照词汇 备注 1 运算符与表达式 ( operator and expression ) 汉语 英语 常量 constant 变量 variable 标识符 identify 关键字 keywords 符号 sign 运算符 operator 语句 statement 语法 syntax 表达式 Expression 初始化 Initialization 数据格式 number format 说明 Declaration 类型转换 type conversion 定义 Define 、 definition 2 条件语句 ( condition statement) 选择 select 表达式 expression 逻辑表达式 logical expression 关系表达式 Relational expression 优先 priority 运算 opera
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 加气混凝土切割工岗位安全教育考核试卷含答案
- 拖拉机涂装加工生产线操作调整工岗中实施考核试卷含答案
- 快件派送员岗位安全宣教考核试卷含答案
- 2026年空间设计高级创意专家招聘笔试试卷 招录14人题库
- 2026年生产数据高级治理师招聘笔试试卷 招录12人
- 2026年浙江省临安市高三数学下册期末考试模拟试卷(黄金题型)附答案
- 2026年四川省万源市高三数学下册期末考试模拟测试卷附答案【综合卷】
- 2026届阿里地区日土县四年级数学第二学期期末质量跟踪监视试题(含解析)
- 2026届阳江市阳西县数学四年级下学期期末试题含答案
- 2026届阜新市太平区四下数学期中质量跟踪监视模拟试题含解析
- 2026中国辅助生殖技术服务渗透率提升路径与区域市场差异调查报告
- 2026中国工业互联网安全威胁态势与防护体系建设研究报告
- 2026年秋人教版一年级数学上册第一单元测试卷可打印
- 2026年全国法律硕士(法学)联考真题及答案
- 《人形机器人数据训练场建设规范》
- 招聘84人!2026年青海省检察机关面向社会公开招聘聘用制书记员考试备考试题及答案解析
- 2026慢性病患者老人秋冬防病保健专题培训课件
- 北京市城市协管员笔试题库及答案详解
- SEMI F63-24 中文版 半导体工艺用超纯水标准指南(2024版)
- 2026年广州市中考语文试卷(含答案及解析)
- 《朝花夕拾》名著导读
评论
0/150
提交评论