现在位置: 首页 > eric发表的所有文章
  • 06月
  • 20日
14 二级C语言 ⁄ 共 275字 二级真题003已关闭评论
所属年份:2010.9;2011.9;2012.3; 【程序填空题】 给定程序中,函数fun的功能是:统计形参s所指的字符串中数字字符出现的次数,并存放在形参t所指的变量中,最后在主函数中输出。例如,若形参s所指的字符串为"abcdef35adgh3kjsdf7",则输出结果为4。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 #include <stdio.h> void fun(char *s, int *t) { int i, n; n=0; /**********found**********/ for(i=0; ___1___ !=0; i++) /**********found**********/ ......
阅读全文
  • 06月
  • 20日
14 二级C语言 ⁄ 共 202字 二级真题002已关闭评论
所属年份:2010.9;2012.3 【程序填空题】 下列给定程序中,函数fun的功能是:计算如下公式前n项的和并作为函数值返回。 例如,当形参n的值为10时,函数返回值为9.612558。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #include <stdio.h> double fun(int n) { int i; double s, t; /**********found**********/ s=__1__; /**********found**********/ for(i=1; i<=__2__; i++) { t=2.0*i; /**********found**********/ ......
阅读全文
  • 06月
  • 20日
14 二级C语言 ⁄ 共 750字 二级真题001已关闭评论
所属年份:2010.9;2011.3;2012.3; 【程序填空题】 下列给定程序中,函数fun的功能是:计算如下公式 直到 ,并且把计算结果作为函数值返回。 例如,若形参e的值为1e-3,则函数返回值为0.551690。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 #include <stdio.h> double fun(double e) { int i, k; double s, t, x; s=0; k=1; i=2; /**********found**********/ x=__1__/4; /**********found**********/ while(x __2__ e) { ......
阅读全文
第1~2套 【程序填空题_1】给定程序中,函数fun的功能是:把形参s所指字符串中下标为奇数右移到下一个奇数位置,最右边被移出字符串的字符绕回到第一个奇数位置,下标为偶数的字符不动(注:字符串长度大于等于2)。例如,形参s所指的字符串为abcdefgh,执行结果为:ahcbedgf。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 #include <stdio.h> void fun(char *s) { int i, n, k; char c; n=0; for(i=0; s[i]!='\0'; i++) n++; /**********found*......
阅读全文
第7~8套 【程序填空题_7】程序通过定义学生结构体变量,存储了学生的学号、姓名和3门课的成绩。所有学生数据均以二进制方式输出到文件中。函数fun的功能是重写形参filename所指文件中最后一个学生的数据,即用新的学生数据覆盖该学生原来的数据,其它学生的数据不变。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 #include <stdio.h> #define N 5 typedef struct student { long sno; char name[10]; floa......
阅读全文
第9~10套 【程序填空题_9】给定程序中,函数fun的功能是:统计形参s所指字符串中数字字符出现的次数,并存放在形参t所指的变量中,最后在主函数中输出。例如,形参s所指的字符串为:abcdef35adgh3kjsd7。输出结果为:4。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 #include <stdio.h> void fun(char *s, int *t) { int i, n; n=0; /**********found**********/ for(i=0; ___1___ !=0; i++) /**********found**********/ if(s[i]>='0'&am......
阅读全文
第5~6套 【程序填空题_5】给定程序中,函数fun的功能是将参数给定的字符串、整数、浮点数写到文本文件中,再用字符串方式从此文本文件中逐个读入,并调用函数atoi和atof将字符串转换成相应的整数、浮点数,然后将其显示在屏幕上。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 #include <stdio.h> #include <stdlib.h> void fun(char *s, int a, double f) { /**********found**********/ ____________ fp; char str[100], str1[100]......
阅读全文
上机真题包括:填空、改错和选择。 【程序填空题_3】给定程序中,函数fun的功能是:利用指针数组形参ss所指字符串数组中的字符串按长到短的顺序排列,并输出排列结果。ss所指字符串数组中共有N个字符串,且串长小于M。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 #include <stdio.h> #include <string.h> #define N 5 #define M 8 void fun(char (*ss)[M]) { char *ps[N],*tp; int i,j,k; for(......
阅读全文
  • 01月
  • 07日
新课程 ⁄ 共 427字 暂无评论
栈的实现很简单 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 #include <stdio.h>   #define MAXLEN 10 typedef struct { int data[MAXLEN]; int top; } SeqStack;   int Push(SeqStack *S, int x) { if(S->top==MAXLEN-1) { printf("栈满!"); return 0; } else { ......
阅读全文
  • 01月
  • 06日
13 数据结构入门 ⁄ 共 356字 暂无评论
折半查找法是高效的查找方法,但前提是所有顺序必须按照关键字来排序。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 #include <stdio.h>   int BinarySearch(int v[ ], int n, int x) { int low=0, high=n-1, mid; while (low <= high) { mid = (low+high)/2; if (x < v[mid]) high = mid - 1; else if (x > v[mid]) low = mid + 1;......
阅读全文
  • 12月
  • 27日
资源 ⁄ 共 74字 谭浩强《C语言程序设计》课件已关闭评论
教材PPT 第1章 C语言基础与顺序结构 第2章 分支结构 第3章 循环结构 第4章 数组 第4章 二维数组 第5章 指针 第6章 函数 基础 第6章 函数 数组 第7章 结构体 第8章 文件
阅读全文
  • 12月
  • 27日
教材内容 ⁄ 共 611字 暂无评论
结构体的声明和使用,指针形式的结构体 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 #include <stdio.h> struct student { char name[10]; char sex; int score; }; main() { struct student s1= {0},s2= {0},s3= {0},max= {0};   printf("Input data:\n"); scanf("%s %c%d",s1.name,&s1.sex,&s1.score); scanf("%s %c%d&q......
阅读全文