str是一个由数字和字母字符组成的字符串,由变量num传入字符串长度。请补充函数proc,该函数的功能是:把字符串str中的数字字符转换成数字并存放到整型数组bb中,函数返回数组bb的长度。
例如,str="abc3de987f9621",结果为:3987621。
注意:部分源程序给出如下。
请勿改动main函数和其他函数中的任何内容,仅在函数proc的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#define M 80
int bb[M];
int proc(char str[],int bb[],int num)
{
int i,n=0;
for(i=0;i { if(【1】) { bb[n]=【2】: n++: } } return 【3】 ; } void main { char str[M]; int mum=0,n,i; printf("Enter a strin9:\n"); gets(str); while(str[num]) num++: n=proc(str,bb,num); printf("\nbb="); for(i=0;i printf("%d",bb[i]); }
学生的记录由学号和成绩组成,M名学生的数据已在主函数中放人结构体数组stu中,请编写函数proc,它的功能是:把指定分数范围之外的学生数据放在b所指的数组中,分数范围之外的学生人数由函数值返回。
例如,输入的分数是70和79,则应当把分数低于70和高于79的学生数据输出,不包含70分和79分的学生数据。主函数中把70放在low中,把79放在heigh中。
注意:部分源程序给出如下。
请勿改动main函数和其他函数中的任何内容,仅在函数proc的花括号中填人所编写的若干语句。
试题程序:
#include
#define M 16
typedef struct
{
char num[10];
int s:
}
STREC;
int proc(STREC*a,STREC*b,int i,int h)
{
}
void main
{
STREC stu[M]={{"GA005",55),{"GA003",96},
{"GA002",80),{"GA004",68),
{"GA001",88},{"GA007",74},
{"GA008",85),{"GA006",89},
{"GA015",90),{"GA013”,53),
{"GA012",66},{"GA014”,82),
{"GA011",73},{"GA017",69),
{"GA018",64),{"GA016",86}};
STREC h[M];
int i,n,low,heigh,t;
printf("Enter 2 integer number low&
heigh:");
scanf("%d%d",&low,&heigh);
if(heigh { t=heigh: heigh=low; low=t; } n=proc(stu,h,low,heigh); printf("The student’S data out %d--%d:\n",low,heigh); for(i=0;i printf("%S%4d\n",h[i].num,h[i].s); //输出指定分数范围外的学生记录 printf("\n"); }
下列给定的程序中,函数proc的功能是:判断字符ch 是,与str所指字符串中的某个字符相同;若相同,则什么也不做,若不同,则将其插在串的最后。请修改程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include
#include
#include
#include
//****found****
void proc(char str,char ch)
{
while(*str &&*str!=ch)str++;
//****found****
if(*str==ch)
{ str[0]=ch;
//****found****
str[1]='0':
}
}
void main
{
char str[81],ch;
system("CLS");
printf("\nPlease enter a string:");
gets(str);
printf("\n Please enter the character to
search:");
ch=getchar;
proc(str,ch);
printf("\nThe result is%s\n",str);
}
str是一个由数字和字母字符组成的字符串,由变量num传入字符串长度。请补充函数proc,该函数的功能是:把字符串str中的数字字符转换成数字并存放到整型数组bb中,函数返回数组bb的长度。
例如,str="abc3de987f9621",结果为:3987621。
注意:部分源程序给出如下。
请勿改动main函数和其他函数中的任何内容,仅在函数proc的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#define M 80
int bb[M];
int proc(char str[],int bb[],int num)
{
int i,n=0;
for(i=0;i { if(【1】) { bb[n]=【2】: n++: } } return 【3】 ; } void main { char str[M]; int mum=0,n,i; printf("Enter a strin9:\n"); gets(str); while(str[num]) num++: n=proc(str,bb,num); printf("\nbb="); for(i=0;i printf("%d",bb[i]); }
有以下程序:
#include<
struct stu { int num;char name[10];int age;}
void fun(struct stu*p)
{ printf("%s\n",(*p).name);}
main
{ struct stu students[3]={{9801,"Zhang".20}, {9802,"Wang",19},{9803,"Zhao",1 8}}
fun(students+2); }
输出的结果是( )。
下列程序执行后的输出结果是( )。
main
{ int x='f';
printf("%c\n",'A'+(x-'a'+1));
}
若有定义:“int a[2][3];”,则对a数组的第i行第j 列元素的正确引用为( )。
有以下程序
#include
main
{ FILE *fp;
int a[10]={1,2,3,0,0},i;
fp=fopen("d2.dat,"wb");
fwrite(a,sizeof(int),5,fp);
fwrite(a,sizeof(int),5,fp);
fclose(fp);
fp=fopen("d2.dat","rb");
fread(a.sizeof(int),10,fp);
fclose(fp);
for(i=0;i<10;i++) printft("%d",a[i]);
}
程序的运行结果是( )。
有下列程序:
main
{ int k=5;
while(--k)
printf("%d",k=1);
printf("\n"); }
执行后的输出结果是( )。
下列程序执行后的输出结果是( )。
main
{ int a[3][3],*p,i;
p=&a[0][0];
for(i=0;i<9;i++) p[i]=i+1;
printf("%d\n",a[1][2]);}
表达式“~0x11”的值是( )。
高级经济师考试试题精选练习(1)
高级经济师考试模拟练习题之单选题(1
高级经济师考试试题精选练习(2)
高级经济师考试试题精选练习(3)
高级经济师考试试题:经济法案例试题精
高级经济师考试模拟试题及答案
高级经济师考试试题及答案:单选练习题
高级经济师考试试题:经济法案例试题精
高级经济师考试模拟题及答案练习(1)
高级经济师考试模拟题及答案练习(2)