wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

2022 高二下半年小测验1 String.h & Function

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

下列何种宣告变数的方法是错误的

a)

#include <stdio.h>

b)

int i[2][3];

c)

char y[6];

d)

string g[5];

2.

下列何者关于“输入字串”是错误的

a)

scanf("%s",str);

b)

gets("str");

c)

scanf("%[^\n]s",str);

d)

scanf("%[^!]s",str);

3.

string.h中,最适合用来比较2字串内容是否相同的function是?

a)

mystrcmp(str1,str2)

b)

strlen(str1,str2)

c)

strcmp(str1,str2)

d)

strcpy(str1,str2)

4.

下列何者关于strcpy(str1,str2)的叙述正确

a)

将str1的内容复制到str2中

b)

将str2的内容复制到str1中

c)

将str2的内容复制到str1中,再把str2内容删除

d)

将str1和str2的内容比较是否相同,相同则return 0

5.

下列何者叙述错误

a)

void类型的function不需要return任何资料给主程式

b)

int类型的function通常会return一个整数值到主程式

c)

function可以return string字串

d)

function可以return char字元

6.

自行设计可以计算字串长度的function,蓝色长方形内应怎么写

a)

x=0;mystr[x]!='\0';x++

b)

length=0;str[x]!='\0';length++

c)

x=0;mystr1[x]!='\0';x++

d)

x=0;str1[x]!='\0';x++

7.

自行设计计算次方的function,蓝色长方形内应填入什么?

a)

a;a<=y;a++

b)

a=0;a<=y;a++

c)

a;y<=a;a++

d)

y;a<=y;y++

8.

撰写void kitty(int k)函数,当主程式呼叫kitty(k)时,萤幕上会显示出k行的“Hello Kitty”。

a)

i<n

b)

i>=n

c)

n<=i

d)

i<=n

9.

撰写一个可以从1累加到k的function,蓝色长方形内应填入什么?

a)

i=i+n;

b)

i=x+i;

c)

x+i;

d)

x=x+i;

10.

撰写int mod(int x,int y)函数找2数相除的余数,蓝色框框内应写?

a)

ans=x%y;

b)

x%y;

c)

x%=y;

d)

ans=x/y;