以下可以删除集合S中的元素x的语句是( )。
A: S.pop(x)
B: S.discard(x)
C: S.remove(x)
D: S.del(x)
A: S.pop(x)
B: S.discard(x)
C: S.remove(x)
D: S.del(x)
举一反三
- 关于集合类型的操作,移除S中所有数据项的是()。 A: S.pop( ) B: S.remove(x) C: S.discard(x) D: S.clear( )
- 经过以下栈运算后,x的值是InitStack(s);Push(s,d);Push(s,e);Pop(s,x);Pop(s,x);GetTop(s,x); A: d B: e C: x D: s
- 写出下列程序段的输出结果(栈的元素类型为char)。 void main(){ Stack S; char x,y; InitStack(S); x= ‘c’; y= ‘k’; Push(S,x); Push(S, ‘a’); Push(S,y); Pop(S,x); Push(S, ‘t’); Push(S,x); Pop(S,x); Push(S, ‘s’); while(!StackEmpty(S)) { Pop(S,y); printf(y); } printf(x); }
- 经过以下运算后, x的值是 _______。InitStack (s); Push(s, a); Push(s, b); Pop(s, x); GetTop(s,x)
- 对于集合S,以下哪些方法是删除元素() A: S.discard(item) B: S.update(item) C: S.pop() D: S.remove(item)