精华10
威望771
K币158 元
注册时间2004-5-8
在线时间62 小时
最后登录2013-12-7
中级战友
- 精华
- 10
- 威望
- 771
- K币
- 158 元
- 注册时间
- 2004-5-8
|
中央财经大学
二OO一年硕士研究生入学考试试题
招生专业:产业经济学
考试科目:C语言程序设计
注意:本试题所有答案应按试题顺序写在答题纸上,只写试题顺序号,
不必抄题,写在试题纸上不得分。
一、 选择题:下列每题选择一个合适的答案(每题2分,共16分)
1.以下函数调用语句中含有( )个实参。
Sub1(f1,(f2,f3),f4,(f5,f6,f7))
A)6 B)4 C)3 D)以上答案都不对。
2.已知: union{ int x;
struct
{ char c1,c2; } b;
} a;
执行语句:a.x=0x3412之后,a,b,c1的值为( )
A)0x34 B)0x3412 C)0x12 D)以上答案都不对
3. 已知函数原形为:
struct tree *f (x1,x2,x3,x4)
int x1,int *x2;
struct tree x3,*x4
其中tree为已定义过的结构,且有下列变量定义:
strcut tree pt,*p; int i;
请选择正确的函数调用语句( )。
A)&pt=f(10,&i,pt,p);
B)p=f(i++,(int *)p,pt,&pt);
C)p=f(i+1,&(i+2),*p,p);
D)f(i+1,&i,p,p);
4. 若有以下程序片段:
char str[]="ac\b\0x56\078\\0";
printf("%d", strler, (str));
A) 3 B) 6 C) 4 D) 8
5. 若fp为文件指针,且文件已正确打开,以下语句的输出结果为本( )
fseek(fp,0,2);
i=ftell(fp);
printf("i=%d",i);
A) fp所指文件的记录长度
B) fp所指文件的当前位置,以字节为单位
C) fp所指文件的当前位置,以字节为单位
D) fp所指文件的长度,以字节为单位
6. 若有以下说明,则有( )不是对strcpy库函数的正确调用。
char * str1="abcd", str2[12]
char *str3="efghkl", *str4, *str5="mnopq";
A) strcpy ( str2, str1 ); B) strcpy (str3 , str1)
C) strcpy (str4 , str1) D) strcpy (sir5 , str1 );
7. 若有如下说明,且0<=k<4,则( )是错误的赋值
int a[4][6], *p, *q[4]
A) p=a B) q[k]=a[k]
C) p=a[k] D) q[k]=&a[0][0]
8. 以下语句段中, ( )不是无限循环。
A) k=50; B) for ( ; ; )
while (1)
{ k=k%50; k++;
if (k>50) break;
}
C) k=32760; D) k=32760;
do while ((k++%2)||(k%2)) k++;
{k+=2;}
while(k>0);
二、度程序:给出程序执行后的输出结果。(第1、2题各5分,第3、4、
5、 6题各6分,共34分)
假设有可运行程序的各文件名为test.exe。使用命令行参数,运行该程序
的格式如下:
test ynop azcb rwza<回车>
请写出下面程序的输出结果。
#include "stdio.h"
#include "string.h"
main(argc,argv)
int argc;
char *argv[];
{ char **p;
sub1( argv+1; argc-1 );
for (p=argv+1;--argc;p++)
printf("%s\n", *p);
}
sub1 (char *s[], int n)
{ int k, j;
char word[20];
for(k=0;k<n;k++)
for (j=k+1;j<n;j++)
if (strcmp(s[k],s[j])>0)
{ strcpy(word, s[k]);
strcpy(s[k], s[j]);
strcpy(s[j], word);
}
}
2. 写出以下程序运行后的输出结果。
#include "stdio.h"
#define N 6
#define M 21
main()
{ int a[M],*p[N],k,j,q;
for(k=0;k<N;k++) {q=k*(k+1)/2; p[k]=&a[q];}
for(k=0;k<N;k++) {*(*(p+k))=1; *(*(p+k)+k)=1;}
for (k=2;k<N;k++ )
for (j=1;j<k;j++)
*(*(p+k)+j)=*(*(p+k-1)+j-1)+*(*(p+k-1)+j);
for( k=0; k<N; k++ )
{for(j=0;j<=k;j++) printf("%4d",*(*(p+k)+j));
printf ("\n");
}
}
3. 写出以下输出结果。
#include "stdio.h"
char str[]="PPPQWLTECH1\1\11Q\1QALLMS1";
main()
int k; char ch;
for ( k=2; (ch=str[k])!='\0'; k++)
{ switch( ch )
{ case 'A': putchar('a'); continue;
case '1': break;
case 1: while( ( ch=str[++k])!='\1'&&ch!='\0');
case 9: putchar('#');
case 'E':
case 'L': continue;
default : putchar(ch); continue;
}
putchar('*');
}
printf("\n");
}
4. 写出下列程序的输出结果。
#include "stdio.h"
main()
{char *s[6]=["BGCD","OFEH","IJKV""ALMN","QXYZ","PRST"};
char **p;
int k;
p=s;
for(k=1;k<4;k++) printf("%c", (*p)[k]);
5. 写出程序运行结果。
#include "stdio.h"
#include "string.h"
void fun( char *w, int m)
char s,*p1, *p2;
p1=w;
p2=w+m-1;
while(p1<p2) , ~;
s=p1++; p1=p2--; *p2=s;
}
main()
{ static char a[]="ABCDEFG";
fun(a,strlen(a));
puts(a)
}
6. 下列程序由两个文件组成,请写出运行结果
/*文件1*/
#include "stdio.h"
int j=4;
main()
{int,k,m,j;
extern int n;
extern int f2( );
k=4;m=3;j=0;
printf("p1=%d\n", f1(n,m));
printf("p2=%d\n", f2(k,m));
printf ("p3=%d\n", f1(n,j));
printf("p4=%d\n", f2(n,j));
printf("n=%d\n", n);
printf("j=%d\n", j);
}
f1(int m, int k)
{int f;
if (n) n=k*n;
j=m+j; f=n%j;
return(f);}
/*文件2*/
int n=2;
f2(int a, int b)
{ static int m;
extern int j;
n=n*j+1; j=j+m+1; m=n+j+a+b;
return(m);
}
三、填空题(每空2分,共22分)
1. 以下程序功能:输入100本书的名称和单价,按照单价进行排序后输
出。
#include "stdio.h"
#define NUM 100
struct book
{ char name[20];
float price;
}
main()
{ struct book term,books[NUM];
int count;
for (count=0;count<NUM; )
{ printf("Input book name and price\n");
scanf("%s%f", [ (1) ] );
sortbook( term, books, count++);
printf("------------------BOOK LIST-----------------\n");
for(count=0;count<NUM;count++)
printbook( [ (2) ] );
}
sortbook( term, pbook, count)
struct book term;
struct book *pbook;
int count;
int k;
struct book *q, [ ( 3 ) ];
for (k=0; k<count; k++,pend++);
for ( ; pbook<pend; pbook++)
if ( pbook->price>term.price) break;
for (q=pend-1; q>=pbook; q--)
[ (4) ];
[ (5) ];
}
printbook(pbook)
struct book *pbook;
{ printf("%-20s %6.2f\n", pbook->name, pbook->price);
}
2.以下程序显示指定文件,在显示文件内容的同时加上行号。
#include "stdio.h"
#include "string.h"
main()
{char s[20],filename[20];
int flag=1, [ ( 6 ) ];
FILE *fp;
printf("Enter filename");
gets(filename);
if((fp=fopen(filename,"r")) [ (7) ] )
{ printf("File open error !\n");
exit(0);
}
while ([ (8) ])
{
while(fgets(s, 20, fp ) [ ( 9 ) ])
{ if ( [ (10) ] ) printf("%3d : %s",++i,s);
else printf("%s ", s);
if ( [ ( 11 )] ) flag=1;
else flag=0;
}
} fclose(fp);
}
四、 编程序(第1题8分,第2题9分,第3题11分,共28分)
1.某人有10张3分的邮票和10张5分的邮票,问使用这些邮票可以组
合出多少种不同面值的邮资。(例如:1张3分邮票加1张5分邮票可
以组成8分的邮资;5张3分的邮票或3张5分的邮票都可以组成同样
面值的邮资。)
2.已知某数列前两项为2和3,其后继项根据前面最后两项的乘积,按下
列规则生成:
(1) 若乘积为一位数,则该乘积即为数列的后继项;
(2) 若乘积为二位数,则该乘积的十位数字和个位数字依次作为数列的
两个后继项。
请编程序生成该数列的前N项,并求前N项的和。要求:生成该数列
后继项及求和过程用函数实现,在主函数中调用该函数。
3.小刚假期同妈妈一起去书店,他选中了N本书,每本书的单价分别为:
p1,p2,p3....,pn元(均为整数),不巧的是:妈妈只带了S(为整数)元钱,
不够买这N本书(即:S<p1+p2+…+pn)。为了让小刚过一个愉快的假
期,妈妈同意将这S元钱全部用来买书。也就是小刚要从所选的N本
书中选出M本,使得这M本的价格和刚好等于S。即:pi1+pi2+
pi3+…+pim=S,请你编程序将所有满足这一条件的i1,i2,i3…im依次打
印出来。 |
评分
-
查看全部评分
|