等级考试上机题目(上课用)
更新时间:2023-07-20 17:25:01 阅读量: 实用文档 文档下载
- 柜员等级考试上机推荐度:
- 相关推荐
第1套
1.程序填空:
#include <stdio.h>
#include <stdlib.h>
#define N 5
typedef struct
{int num;
char name[10];
char tel[10];
}STYPE;
void check();
/**********found**********/
int fun(___1___ *std)
{
/**********found**********/
___2___ *fp; int i;
if((fp=fopen("myfile5.dat","wb"))==NULL)
return(0);
printf("\nOutput data to file !\n");
for(i=0; i<N; i++)
/**********found**********/
fwrite(&std[i], sizeof(STYPE), 1, ___3___);
fclose(fp);
return (1);
}
main()
{STYPE s[10]={ {1,"aaaaa","111111"},{1,"bbbbb",
"222222"},{1,"ccccc","333333"},{1,"ddddd","444444"},{1,"eeeee", "555555"}};
int k;
k=fun(s);
if (k==1)
{printf("Succeed!"); check();}
else
printf("Fail!");
}
void check()
1
{FILE *fp; int i;
STYPE s[10];
if((fp=fopen("myfile5.dat","rb"))==NULL)
{printf("Fail !!\n"); exit(0);}
printf("\nRead file and output to screen :\n");
printf("\n num name tel\n");
for(i=0; i<N; i++)
{fread(&s[i],sizeof(STYPE),1, fp);
printf("%6d %s %s\n",s[i].num, s[i].name,s[i].tel);
}
fclose(fp);
}
2.改错题
#include <stdio.h>
#include <string.h>
void fun (char *s, char *t)
{int i, sl;
sl = strlen(s);
/************found************/
for(i=0; i<=s1; i ++)
t[i] = s[i];
for (i=0; i<sl; i++)
t[sl+i] = s[sl-i-1];
/************found************/
t[sl] = '\0';
}
main()
{char s[100], t[100];
printf("\nPlease enter string s:"); scanf("%s", s);
fun(s, t);
printf("The result is: %s\n", t);
}
2
3.程序设计题
#include <stdio.h>
void fun(int a, int b, long *c)
{
}
main()
{int a,b; long c;
void NONO ();
printf("Input a, b:"); scanf("%d,%d", &a, &b);
fun(a, b, &c);
printf("The result is: %d\n", c);
NONO();
}
void NONO ()
{/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。*/
FILE *rf, *wf ;
int i, a,b ; long c ;
rf = fopen("in.dat", "r");
wf = fopen("out.dat","w");
for(i = 0 ; i < 10 ; i++) {
fscanf(rf, "%d,%d", &a, &b);
fun(a, b, &c);
fprintf(wf, "a=%d,b=%d,c=%ld\n", a, b, c);
}
fclose(rf);
fclose(wf);
}
3
第2套题
1.程序填空题
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void WriteText(FILE *);
void ReadText(FILE *);
main()
{FILE *fp;
if((fp=fopen("myfile4.txt","w"))==NULL)
{printf(" open fail!!\n"); exit(0);}
WriteText(fp);
fclose(fp);
if((fp=fopen("myfile4.txt","r"))==NULL)
{printf(" open fail!!\n"); exit(0);}
ReadText(fp);
fclose(fp);
}
/**********found**********/
void WriteText(FILE ___1___)
{char str[81];
printf("\nEnter string with -1 to end :\n");
gets(str);
while(strcmp(str,"-1")!=0) {
/**********found**********/
fputs(___2___,fw); fputs("\n",fw);
gets(str);
}
}
void ReadText(FILE *fr)
{char str[81];
printf("\nRead file and output to screen :\n");
fgets(str,81,fr);
while(!feof(fr)) {
/**********found**********/
printf("%s",___3___);
fgets(str,81,fr);
4
}
}
2.程序修改题
#include <stdio.h>
/************found************/
void fun (long s, long t)
{ long sl=10;
*t = s % 10;
while (s > 0)
{s = s/100;
*t = s%10 * sl + *t;
/************found************/
sl = sl*100;
}
}
main()
{long s, t;
printf("\nPlease enter s:"); scanf("%ld", &s);
fun(s, &t);
printf("The result is: %ld\n", t);
}
3.程序设计题
#include <stdio.h>
void fun(int a, int b, long *c)
{
5
}
main()
{int a,b; long c;
void NONO ();
printf("Input a, b:");
scanf("%d,%d", &a, &b);
fun(a, b, &c);
printf("The result is: %ld\n", c);
NONO();
}
void NONO ()
{/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。*/
FILE *rf, *wf ;
int i, a,b ; long c ;
rf = fopen("in.dat", "r");
wf = fopen("out.dat","w");
for(i = 0 ; i < 10 ; i++) {
fscanf(rf, "%d,%d", &a, &b);
fun(a, b, &c);
fprintf(wf, "a=%d,b=%d,c=%ld\n", a, b, c);
}
fclose(rf);
fclose(wf);
}
第3套
1.程序填空题
#include <math.h>
#include <stdio.h>
int fun(char *fname)
{FILE *fp; int i,n; float x;
if((fp=fopen(fname, "w"))==NULL) return 0;
6
for(i=1;i<=10;i++)
/**********found**********/
fprintf(___1___,"%d %f\n",i,sqrt((double)i));
printf("\nSucceed!!\n");
/**********found**********/
___2___;
printf("\nThe data in file :\n");
/**********found**********/
if((fp=fopen(___3___,"r"))==NULL)
return 0;
fscanf(fp,"%d%f",&n,&x);
while(!feof(fp))
{printf("%d %f\n",n,x); fscanf(fp,"%d%f", &n,&x);}
fclose(fp);
return 1;
}
main()
{char fname[]="myfile3.txt";
fun(fname);
}
2.程序填空题
#include <stdio.h>
#include <stdlib.h>
fun (int n, int *a)
{int i, j, p, t;
for (j = 0; j<n-1 ; j++)
{p = j;
/************found************/
for (i=j+1; i<n-1 ; i++)
if (a[p]>a[i])
/************found************/
t=i;
if (p!=j)
{t = a[j]; a[j] = a[p]; a[p] = t;}
}
}
putarr(int n, int *z)
{int i;
for (i = 1; i <= n; i++, z++)
7
{printf("%4d", *z);
if (!(i%10)) printf("\n");
} printf("\n");
}
main()
{int aa[20]={9,3,0,4,1,2,5,6,8,10,7}, n=11;
printf("\n\nBefore sorting %d numbers:\n", n); putarr(n, aa); fun(n, aa);
printf("\nAfter sorting %d numbers:\n", n); putarr(n, aa);
}
3.程序设计题
#include <stdio.h>
void fun(int a, int b, long *c)
{
}
main()
{int a,b; long c;
void NONO ();
printf("Input a, b:");
scanf("%d,%d", &a, &b);
fun(a, b, &c);
printf("The result is: %ld\n", c);
NONO();
}
void NONO ()
{/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。*/
FILE *rf, *wf ;
int i, a,b ; long c ;
8
rf = fopen("in.dat", "r");
wf = fopen("out.dat","w");
for(i = 0 ; i < 10 ; i++) {
fscanf(rf, "%d,%d", &a, &b);
fun(a, b, &c);
fprintf(wf, "a=%d,b=%d,c=%ld\n", a, b, c);
}
fclose(rf);
fclose(wf);
}
第4套
1.程序填空题
#include <stdio.h>
#include <stdlib.h>
int fun(char *source, char *target)
{FILE *fs,*ft; char ch;
/**********found**********/
if((fs=fopen(source, ___1___))==NULL)
return 0;
if((ft=fopen(target, "w"))==NULL)
return 0;
printf("\nThe data in file :\n");
ch=fgetc(fs);
/**********found**********/
while(!feof(___2___))
{putchar(ch);
/**********found**********/
fputc(ch,___3___);
ch=fgetc(fs);
}
fclose(fs); fclose(ft);
printf("\n\n");
return 1;
}
main()
9
{char sfname[20] ="myfile1",tfname[20]="myfile2";
FILE *myf; int i; char c;
myf=fopen(sfname,"w");
printf("\nThe original data :\n");
for(i=1; i<30; i++){c='A'+rand()%25;fprintf(myf, "%c",c);
printf("%c",c);}
fclose(myf);printf("\n\n");
if (fun(sfname, tfname) ) printf("Succeed!");
else printf("Fail!");
}
2.程序改错题
#include <stdio.h>
void fun (long s, long *t)
{int d;
long sl=1;
*t = 0;
while (s > 0)
{d = s%10;
/************found************/
if (d%2=0)
{ *t=d* sl+ *t;
sl *= 10;
}
/************found************/
s \= 10;
}
}
main()
{long s, t;
printf("\nPlease enter s:"); scanf("%ld", &s);
fun(s, &t);
printf("The result is: %ld\n", t);
}
3.程序设计题
10
#include <stdio.h>
void fun(int a, int b, long *c)
{
}
main()
{int a,b; long c;
void NONO ();
printf("Input a, b:");
scanf("%d,%d", &a, &b);
fun(a, b, &c);
printf("The result is: %ld\n", c);
NONO();
}
void NONO ()
{/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。*/
FILE *rf, *wf ;
int i, a,b ; long c ;
rf = fopen("in.dat", "r");
wf = fopen("out.dat","w");
for(i = 0 ; i < 10 ; i++) {
fscanf(rf, "%d,%d", &a, &b);
fun(a, b, &c);
fprintf(wf, "a=%d,b=%d,c=%ld\n", a, b, c);
}
fclose(rf);
fclose(wf);
}
11
第5套
1.程序填空题
#include <stdio.h>
#include <stdlib.h>
#define N 8
typedef struct list
{int data;
struct list *next;
} SLIST;
void fun(SLIST *h, int x)
{SLIST *p, *q, *s;
s=(SLIST *)malloc(sizeof(SLIST));
/**********found**********/
s->data=___1___;
q=h;
p=h->next;
while(p!=NULL && x>p->data) {
/**********found**********/
q=___2___;
p=p->next;
}
s->next=p;
/**********found**********/
q->next=___3___;
}
SLIST *creatlist(int *a)
{SLIST *h,*p,*q; int i;
h=p=(SLIST *)malloc(sizeof(SLIST));
for(i=0; i<N; i++)
{q=(SLIST *)malloc(sizeof(SLIST));
q->data=a[i]; p->next=q; p=q;
}
p->next=0;
return h;
}
void outlist(SLIST *h)
{SLIST *p;
12
p=h->next;
if (p==NULL) printf("\nThe list is NULL!\n");
else
{printf("\nHead");
do {printf("->%d",p->data); p=p->next;} while(p!=NULL);
printf("->End\n");
}
}
main()
{SLIST *head; int x;
int a[N]={11,12,15,18,19,22,25,29};
head=creatlist(a);
printf("\nThe list before inserting:\n"); outlist(head);
printf("\nEnter a number : "); scanf("%d",&x);
fun(head,x);
printf("\nThe list after inserting:\n"); outlist(head);
}
2.程序改错题
#include <stdio.h>
long fun (long num)
{
/************found************/
long k;
do
{k*=num%10 ;
/************found************/
num\=10 ;
} while(num);
return (k);
}
main()
{long n ;
printf("\nPlease enter a number:"); scanf("%ld",&n);
printf("\n%ld\n",fun(n));
}
3.程序设计题
13
#include <stdio.h>
float fun (float *a , int n)
{
}
main()
{float score[30]={90.5, 72, 80, 61.5, 55}, aver;
void NONO ();
aver = fun(score, 5);
printf("\nAverage score is: %5.2f\n", aver);
NONO ();
}
void NONO ()
{/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。*/
FILE *fp, *wf ;
int i, j ;
float aver, score[5] ;
fp = fopen("in.dat","r");
wf = fopen("out.dat","w");
for(i = 0 ; i < 10 ; i++) {
for(j = 0 ; j < 5 ; j++) fscanf(fp,"%f,",&score[j]);
aver = fun(score, 5);
fprintf(wf, "%5.2f\n", aver);
}
fclose(fp);
fclose(wf);
}
14
第6套
1.程序填空题
#include <stdio.h>
#include <stdlib.h>
#define N 8
typedef struct list
{int data;
struct list *next;
} SLIST;
void fun(SLIST *p)
{SLIST *t, *s;
t=p->next; s=p;
while(t->next != NULL)
{s=t;
/**********found**********/
t=t->___1___;
}
/**********found**********/
printf(" %d ",___2___);
s->next=NULL;
/**********found**********/
free(___3___);
}
SLIST *creatlist(int *a)
{SLIST *h,*p,*q; int i;
h=p=(SLIST *)malloc(sizeof(SLIST));
for(i=0; i<N; i++)
{q=(SLIST *)malloc(sizeof(SLIST));
q->data=a[i]; p->next=q; p=q;
}
p->next=0;
return h;
}
void outlist(SLIST *h)
{SLIST *p;
p=h->next;
if (p==NULL) printf("\nThe list is NULL!\n");
15
else
{printf("\nHead");
do {printf("->%d",p->data); p=p->next;} while(p!=NULL);
printf("->End\n");
}
}
main()
{SLIST *head;
int a[N]={11,12,15,18,19,22,25,29};
head=creatlist(a);
printf("\nOutput from head:\n"); outlist(head);
printf("\nOutput from tail: \n");
while (head->next != NULL){
fun(head);
printf("\n\n");
printf("\nOutput from head again :\n"); outlist(head);
}
}
2.程序改错题
#include <stdio.h>
/************found************/
fun (char a)
{if (*a)
{fun(a+1);
/************found************/
printf("%c" *a);
}
}
main()
{char s[10]="abcd";
printf("处理前字符串=%s\n处理后字符串=", s);
fun(s); printf("\n");
}
3.程序设计题
16
#include <stdio.h>
char *fun (char *s, char *t)
{
}
main()
{char a[20],b[20];
void NONO ();
printf("Input 1th string:");
gets(a);
printf("Input 2th string:");
gets(b);
printf("%s\n",fun (a, b));
NONO ();
}
void NONO ()
{/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。*/
FILE *fp, *wf ;
int i ;
char a[20], b[20] ;
fp = fopen("in.dat","r");
wf = fopen("out.dat","w");
for(i = 0 ; i < 10 ; i++) {
fscanf(fp, "%s %s", a, b);
fprintf(wf, "%s\n", fun(a, b));
}
fclose(fp);
fclose(wf);
}
17
第7套
1.程序填空题
#include <stdio.h>
#include <stdlib.h>
#define N 8
typedef struct list
{int data;
struct list *next;
} SLIST;
void fun(SLIST *h)
{SLIST *p, *q;
p=h->next;
if (p!=NULL)
{q=p->next;
while(q!=NULL)
{if (p->data==q->data)
{p->next=q->next;
/**********found**********/
free(___1___);
/**********found**********/
q=p->___2___;
}
else
{p=q;
/**********found**********/
q=q->___3___;
}
}
}
}
SLIST *creatlist(int *a)
{SLIST *h,*p,*q; int i;
h=p=(SLIST *)malloc(sizeof(SLIST));
for(i=0; i<N; i++)
{q=(SLIST *)malloc(sizeof(SLIST));
q->data=a[i]; p->next=q; p=q;
}
18
p->next=0;
return h;
}
void outlist(SLIST *h)
{SLIST *p;
p=h->next;
if (p==NULL) printf("\nThe list is NULL!\n");
else
{printf("\nHead");
do {printf("->%d",p->data); p=p->next;} while(p!=NULL);
printf("->End\n");
}
}
main()
{SLIST *head; int a[N]={1,2,2,3,4,4,4,5};
head=creatlist(a);
printf("\nThe list before deleting :\n"); outlist(head);
fun(head);
printf("\nThe list after deleting :\n"); outlist(head);
}
2.程序修改题
#include <stdio.h>
#define N 20
void fun(int a[], int n)
{int i, j, t, p;
for (j = 0 ;j < n-1 ;j++) {
/************found************/
p = j
for (i = j;i < n; i++)
if(a[i] < a[p])
/************found************/
p = j;
t = a[p] ; a[p] = a[j] ; a[j] = t;
}
}
main()
{
int a[N]={9,6,8,3,-1},i, m = 5;
printf("排序前的数据:");
for(i = 0;i < m;i++) printf("%d ",a[i]); printf("\n");
19
fun(a,m);
printf("排序后的数据:");
for(i = 0;i < m;i++) printf("%d ",a[i]); printf("\n");
}
3.程序设计题
#include <stdio.h>
#define M 100
void fun (int m, int *a , int *n)
{
}
main()
{int aa[M], n, k;
void NONO ();
fun (50, aa, &n);
for (k = 0; k < n; k++)
if((k+1)%20==0) printf("\n");
else printf("%4d", aa[k]);
printf("\n");
NONO();
}
void NONO ()
{/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。*/
FILE *fp, *wf ;
int i, n, j, k, aa[M], sum ;
fp = fopen("in.dat","r");
20
wf = fopen("out.dat","w");
for(i = 0 ; i < 10 ; i++) {
fscanf(fp, "%d,", &j);
fun(j, aa, &n);
sum = 0 ;
for(k = 0 ; k < n ; k++) sum+=aa[k] ;
fprintf(wf, "%d\n", sum);
}
fclose(fp);
fclose(wf);
}
第8套
1.程序填空题
#include <stdio.h>
#include <stdlib.h>
#define N 8
typedef struct list
{int data;
struct list *next;
} SLIST;
SLIST *creatlist(char *);
void outlist(SLIST *);
int fun(SLIST *h, char ch)
{SLIST *p; int n=0;
p=h->next;
/**********found**********/
while(p!=___1___)
{n++;
/**********found**********/
if (p->data==ch) return ___2___;
else p=p->next;
}
return 0;
}
main()
{SLIST *head; int k; char ch;
21
正在阅读:
等级考试上机题目(上课用)07-20
学术论文的规范表达主要涉及哪些内容?05-17
最新整理县级公立医院药品“零差率”销售工作方案范文03-16
涨停基因公式小结04-22
广播系统调试测试10-15
人力资源管理毕业设计(论文)-人才招聘工作优化对策研究 -05-18
今日基督徒普遍的可怜的光景01-26
中国印制电路专业技术职称工程技术系列-中国印制电路行业协会05-22
华为外部环境分析09-25
- 教学能力大赛决赛获奖-教学实施报告-(完整图文版)
- 互联网+数据中心行业分析报告
- 2017上海杨浦区高三一模数学试题及答案
- 招商部差旅接待管理制度(4-25)
- 学生游玩安全注意事项
- 学生信息管理系统(文档模板供参考)
- 叉车门架有限元分析及系统设计
- 2014帮助残疾人志愿者服务情况记录
- 叶绿体中色素的提取和分离实验
- 中国食物成分表2020年最新权威完整改进版
- 推动国土资源领域生态文明建设
- 给水管道冲洗和消毒记录
- 计算机软件专业自我评价
- 高中数学必修1-5知识点归纳
- 2018-2022年中国第五代移动通信技术(5G)产业深度分析及发展前景研究报告发展趋势(目录)
- 生产车间巡查制度
- 2018版中国光热发电行业深度研究报告目录
- (通用)2019年中考数学总复习 第一章 第四节 数的开方与二次根式课件
- 2017_2018学年高中语文第二单元第4课说数课件粤教版
- 上市新药Lumateperone(卢美哌隆)合成检索总结报告
- 上机
- 等级考试
- 题目
- 上课
- 《李时珍》教学简案Microsoft Word 文档
- 2021年八年级上浮力竞赛辅导教师版有答案
- 让探究性学习成为高中生物课堂教学的主旋律
- 第20章 电与磁 复习
- 河南高体验磨练考模式下文科和理科学生
- 2012年下半年六年级数学竞赛试题
- 地方农业院校非农专业人才培养模式的研究与实践——以高分子材料与工程专业为例
- 英语必修3 Unit 4 主语从句
- 宏微观经济学复习题
- 浅谈绞缆机的修理
- 2010年维护社会稳定工作总结
- 二级路由器设置方法
- 成都市统筹城乡医疗保障制度的现状与问题
- 浅谈民间纠纷分类调解五法
- 和谐社会构建与地方政府信用治理
- 生产部管理评审报告
- 一线员工晋升标准@(1)
- 股权转让协议书(参考范文)
- 2014安康事业单位笔试公共基础知识法律知识:宪法之民族自治地方的自治机关篇 (40)
- ISO27001:2013中英文对照