C语言

第1141题

有以下程序

#include <stdio.h>
typedef struct stu
{
char name[10];
char gender;
int score;
} STU;
void f(STU a, STU *b)
{
*b = a;
printf("%s,%c,%d,", b->name, b->gender, b->score);
}
main()
{
STU a={"Zhao", 'm', 290}, b={"Qian", 'f', 350};
f(a,&b);
printf("%s,%c,%d\n", b.name, b.gender, b.score);
}

程序运行后的输出结果是()。

第1142题

有以下程序:

#include <stdio.h>
typedef struct stu
{
char name[10];
char gender;
int score;
} STU;
void f(STU a, STU *b)
{
a = *b;
printf("%s,%c,%d,", a.name, a.gender, a.score);
}
main()
{
STU a={"Zhao", 'm', 290}, b={"Qian", 'f', 350};
f(a,&b);
printf("%s,%c,%d\n", a.name, a.gender, a.score);
}

程序运行后的输出结果是()。

第1143题

有以下程序:

#include <stdio.h>
typedef struct stu
{
char name[10];
char gender;
int score;
} STU;
void f(STU *a, STU *b)
{
*b = *a;
printf("%s,%c,%d,", b->name, b->gender, b->score);
}
main()
{
STU a={"Zhao", 'm', 290}, b={"Qian", 'f', 350};
f(&a,&b);
printf("%s,%c,%d\n", b.name, b.gender, b.score);
}

程序的运行结果是()。

第1144题

有以下函数:

#include <stdio.h>
struct stu
{
int num;
char name[10];
int age;
}voi; d fun(struct stu *p)
{
printf("%s\n", p->name);
}
main()
{
struct stu x[3] = {{01,"Zhang",20}, {02,"Wang",19}, {03,"Zhao",18}};
fun(x+2);
}

程序运行后的输出结果是()。

第1145题

有以下程序:

#include <stdio.h>
struct STU
{
int num;
float TotalScore;
}voi; d f(struct STU p)
{
struct STU s[2] = {{20044,550}, {20045,537}};
p.num = s[1].num;
p.TotalScore = s[1].TotalScore;
}
main()
{
struct STU s[2] = {{20041,703}, {20042,580}};
f(s[0]);
printf("%d %3.0f\n", s[0].num, s[0].TotalScore);
}

程序运行后的输出结果是()。

第1146题

有以下程序:

#include <stdio.h>
#include <string.h>
typedef struct
{
char name[10];
char sex;
int age;
}STU;
void fun(STU *t)
{
strcpy((*t).name,"Tong");
(*t).age++;
}
main()
{
STU s[2] = {"Hua", 'm', 18, "Qin", 'f', 19};
fun(s+1);
printf("%s,%d,%s,%d\n", s[0].name, s[0].age, s[1].name, s[1].age);
}

程序运行后的输出结果是()。

第1147题

有以下程序:

#include <stdio.h>
#include <string.h>
typedef struct
{
char name[10];
char sex;
int age;
}STU;
void fun(STU t)
{
strcpy(t.name,"Tong");
t.age++;
}
main()
{
STU s[2] = {"Hua", 'm', 18, "Qin", 'f', 19};
fun(s[1]);
printf("%s,%d,%s,%d\n", s[0].name, s[0].age, s[1].name, s[1].age);
}

程序运行后的输出结果是()。

第1148题

有以下程序:

#include <stdio.h>
#include <string.h>
struct A
{
int a;
char b[10];
double c;
}voi; d f(struct A t);
main()
{
struct A a={1001,"ZhangDa",1098.0};
f(a);
printf("%d,%s,%6.1f\n",a.a,a.b,a.c);
}void f(struct A t)
{
t.a=1002;
strcpy(t.b,"ChangRong");
t.c=1202.0;
return t;
}

程序运行后的输出结果是()。

第1149题

有以下程序:

#include <stdio.h>
#include <string.h>
struct A
{
int a;
char b[10];
double c;
}st;ruct A f(struct A t);
main()
{
struct A a={1001,"ZhangDa",1098.0};
a=f(a);
printf("%d,%s,%6.1f\n",a.a,a.b,a.c);
}struct A f(struct A t)
{
t.a=1002;
strcpy(t.b,"ChangRong");
t.c=1202.0;
return t;
}

程序运行后的输出结果是()。

第1150题

有以下程序

#include <stdio.h>
struct S
{
int n;
int a[20];
}voi; d f(struct S *p)
{
int i,j,t;
for(i=0;i<p->n-1;i++)
for(j=i+1;j<p->n;j++)
if(p->a[i]>p->a[j])
{
t=p->a[i];
p->a[i]=p->a[j];
p->a[j]=t;
}
}
main()
{
int i;
struct S s = {10,{2,3,1,6,8,7,5,4,10,9}};
f(&s);
for(i=0;i<s.n;i++)printf("%d,", s.a[i]);
}

程序运行后的输出结果是()。

第1151题

有以下程序

#include <stdio.h>
struct S
{
int n;
int a[20];
}voi; d f(int *a, int n)
{
int i;
for(i=0;i<n-1;i++)
a[i]+=i;
}
main()
{
int i;
struct S s = {10,{2,3,1,6,8,7,5,4,10,9}};
f(s.a,s.n);
for(i=0;i<s.n; i++) printf("%d,", s.a[i]);
}

程序运行后的输出结果是()。

第1152题

有如下程序:

#include <stdio.h>
struct pair
{
int first,second;
}st;ruct pair get_min_max(int*array, int len)
{
int i;
struct pair res;
res.first=array[0];
res.second=array[0];
for(i=1;i<len;i++)
{
if(array[i]<res.first)
res.first=array[i];
if(array[i]>res.second)
res.second=array[i];
}return res;
}
main()
{
int array[5]={9,1,3,4};
struct pair min_max = get_min_max(array,5);
printf("min=%d,max=%d\n", min_max.first, min_max.second);
}

程序运行后的输出结果是()。

第1153题

有如下程序:

#include <stdio.h>
#include <string.h>
struct S
{
char name[10];
}voi; d change(struct S *data,int value)
{
strcpy(data->name, "****");
value=13;
}
main()
{
struct S input;
int num = 4;
strcpy(input.name, "THIS");
change(&input,num);
printf("%s,%d\n",input.name,num);
}

程序运行后的输出结果是()。

第1154题

有以下程序

#include <stdio.h>
#include <string.h>
struct S
{
char name[10];
}voi; d change(struct S *data, int value)
{
strcpy(data->name, "#");
value = 6;
}
main()
{
struct S input;
int num = 3;
strcpy(input.name, "OK");
change(&input, num);
printf("%s,%d\n", input.name, num);
}

程序运行后的输出结果是()。

第1155题

为了建立如图所示的存储结构(即每个结点含两个域,data是数据域,next是指向结点的指针域)

链表结构.png

则在下面结构体定义中划线处应填入的选项是()。

struct link
{
char data;
______;
}node;
第1156题

若有以下定义和语句:

struct st
{
int n;
struct st*next;
}st;ruct st a[3] = {5,&a[0], 6,&a[1],7,&a[2]}, *p;
p = &a[0];

则值为6的表达式是(提示:运算符->的优先级高于++)()。

第1157题

若有以下程序段

struct st
{
int n;
struct st*next;
}st;ruct st a[3] = {5,&a[1],7,&a[2],9,'\0'}, *p;
p = &a[0];

则以下选项中值为6的表达式是()。

第1158题

有以下程序:

#include <stdio.h>
struct link
{
int data;
struct link *next;
};
main()
{
struct link *h,a,b;
h=&a;
a.data=10;
a.next = &b;
b.data = 20;
}

程序运行时不能输出10,20的语句是()。

第1159题

有以下程序:

#include <stdio.h>
main()
{
struct node
{
int n;
} *sp;truct node *next;
struct node x[3] = {{2,x+1},{4,x+2},{6,NULL}};
p=x;
printf("%d,",p->n);
printf("%d\n",p->next->n);
}

程序运行后的输出结果是()。

第1160题

假定已建立以下数据链表结构,且指针p和q已指向如下图所示的结点:

链表结构

则以下选项中可将q所指结点从链表中删除并释放该结点的语句是()。