全国自考高级语言程序设计(一)精选试题及答案,内含单项选择题、填空题、程序分析题、程序填充题、程序设计题。
编写程序,用以建立某班级的学生档案信息,每个学生档案信息包括姓名邮编、电话。
输入三个国家的名称按字母顺序排序后输出。
#include< stdio.h>
#include< string.h>
int main(void)
{
char *s[ ]={"China",'America,Russia}*p/*定义指针数组s和指针变p*/
int i,j,k=3;
for(i=0;ifor(j=0;j<______;j++)
if( strcmp(s[j], s[j+1])>0)
p=s[j];
s[j]=______;
s[j+1]=p;
}
for(i=0; iprintf("%s\n",s[i]);return 0;}
printf("%s\n",s[i]);
return 0;
用指针方法实现:输入8个整数,将其中的最大数和最后一个数交换,最小数和第1个数交换,然后将8个整数倒序输出。
下面的程序是使用结构体类型来计算复数m和n的差。
#include<stdio.h>
void main()
struct comp
float re; float im;
};
________m,n,z;
scanf("%f, %f, %f, %f", &m. re, &m. im, &n. re, &n. im);
z.re=________,z.im=________;
printf("%6.2f+%6. 2fi \n", z. re, z. im);
将文本文件r.txt中的字符逐一读出并显示在屏幕上。
#include< stdio.h>
#include< stdlib.h>
FILE*fp
char ch;
if((fp fopen("r. txt",______))==NULL)/*第一空*/
printf("can't open file! \n"); exit(0);
printf("读文件并显示:\n");
while(! feof(fp))
ch= fgetc(fp);
printf("%c",_____);/*第二空*/
printf("\n");
fclose(_______);/*第三空*/
struct stu
int num;
char name[10];
int age;
void py(struct stu *p)
printf("%s\n",( *p). name);
struct stu student [3]={{ 1001, "Sun",25}
{1002,"Ling",23},
{1003,"Shen",22}};
py(student+2)
int i;
char *country[ ]={"Brazil", "Russia", "India","China", "SouthAfrica"};
for(i=1;i<4;i+=2)
printf("%s\n", country[i]);
C盘中p1.c.txt文件的内容为: abcde。盘中p1.c.txt为空文档。
FILE *f1, *f2;
int k;
if((f1= fopen("C: \\pl. c. txt", "r"))= =NULL)
printf("can not open file!\n");
exit(0)
if((f2= fopen "D: \\p1.c. txt", w")) =NULL)
printf("can not open file! \n");
exit(0);
for(k=1;k<=500;k++)
if( feof(f1))break;
fputc(fgetc(f1), f2);
printf("复制成功");
fclose(f1);
fclose(f2);
设 float[6][4];,则数组a中第一维下标的最大值是________。
#define MAX(x,y,z)(x >y? (x>z? x: z): ( y>z? y:z))
int a=3,b=4,c=5;
printf("%d,",MAX(a,b,c));
printf("%d,",MAX(a*b,b,b+a));
printf("%d \n", MAX(a, b+c, a*c));
相关试卷
管理信息系统2009年1月真题及答案
管理信息系统2009年10月真题及答
管理信息系统2010年1月真题及答案
管理信息系统2010年10月真题及答
管理信息系统2011年1月真题及答案
管理信息系统2011年10月真题及答
管理信息系统2012年4月真题及答案
管理信息系统2012年10月真题及答
管理信息系统2013年4月真题及答案
管理信息系统2013年10月真题及答