网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
已知s={1,20,25},则通过“s.add([2,3])”可以向s中添加一个新的列表类型的元素。
参考答案和解析
错误
更多 “已知s={1,20,25},则通过“s.add([2,3])”可以向s中添加一个新的列表类型的元素。” 相关考题
考题
请使用VC6或使用【答题】菜单打开考生文件夹proj3下的工程proj3,其中包含了类IntegerSet和主函数main的定义。一个IntegerSet对象就是一个整数的集合,其中包含0个或多个无重复的整数;为了便于进行集合操作,这些整数按升序存放在成员数组elem的前若干单元中。成员函数add的作用是将一个元素添加到集合中(如果集合中不存在该元素),成员函数remove从集合中删除指定的元素(如果集合中存在该元素)。请编写成员函数remove。在main函数中给出了一组测试数据,此时程序的正确输出结果应为: 2 3 4 5 27 28 31 66 75 2 3 4 5 6 27 28 31 56 75 2 3 4 5 6 19 27 28 31 66 75 3 4 5 6 19 27 28 31 66 75 3 4 5 6 19 27 28 31 66 75 要求: 补充编制的内容写在“//***********333***********”与“//***********666***********”之间,不得修改程序的其他部分。 注意:程序最后将结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件,并且在本程序中调用。 //IntegorSet.h ifndef INTEGERSET define INTEGERSET includeiostream using namespace std; const int MAXELEMENTS=100; //集合最多可拥有的元素个数 class IntegerSet{ int elem[MAXELEMENTS]; //用于存放集合元素的数组 int counter; //用于记录集合中元素个数的计数器 puhlic: IntegerSet:counter(0){} //创建一个空集合 IntegerSet(int data[],int size); //利用数组提供的数据创建一个整数集合 void add(int element); //添加一个元素到集合中 void remeve(int element); //删除集合中指定的元素 int getCountconst{return counter;} //返回集合中元素的个数 int getElement(int i)const{retum elem[i];}//返回集合中指定的元素 void showconst; }; void WriteToFile(char*); endif //main.cpp include”IntegerSet.h” includeinmanip IntegerSet::IntegerSet(int data[],int size):counter(0){ for(int i=0;isize;i++) add(data[i]); } } void IntegerSet::add(int element){ int j; //从后往前寻找第一个小于等于element的元素 for(j=counter;j0;j-) if(element=elem[j一1])break; //如果找到的是等于element的元素,说明要添加的元素已经存在,直接返回 if(j0) if(element==elem[j-1])return; //如果找到的是小于element的元素,j就是要添加的位置 //该元素及其后面的元素依次后移,腾出插入位置 for(int k=counter;kj;k一) elem[k]=elem[k一1]; elem[j]=element;//将element插入到该位置 counter++; //计数器加l } void IntegerSet::remove(int element){ //***************333*************** //***************666*************** void IntegerSet::showconst{ for(int i=0;igetCount;i++) coutsetw(4)getElement(i); coutendl: } int main{ int d[]={5,28,2,4,5,3,2,75,27,66,31}; IntegerSet S(d,11);S.show; S.add(6); s.show; S.add(19); S.show; S.remove(2); s.show; S.add(4); S.show; writeToFile(””); return 0; }
考题
下列Application程序中,指定as为字符串数组类型,先创建一个HashSet对象并赋值,然后在屏幕输出s,请将程序补充完整。import java.util.*;public class test17_1{public static void main(String[] args){__________s=new HashSet();s.add("Hello");s.add("World");s.add(new Character('我'));s.add(new Integer(23));s.add("Hello");__________as={"W","o","r","1","d"};s.add(as);s.add(null);s.add(new Integer(23));s.add(null);System.out.println(__________);
考题
下面的程序的运行结果是__________type Slice []intfunc NewSlice() Slice {return make(Slice, 0)}func (s* Slice) Add(elem int) *Slice {*s = append(*s, elem)fmt.Print(elem)return s}func main() { s := NewSlice()defer s.Add(1).Add(2)s.Add(3)}
考题
已知一个不带头结点单链表的头指针为L,则在表头元素之前插入一个新结点*s的语句为:()A、 L=s; s->next=L;B、 s->next=L; L=s;C、 s=L; s->next=L;D、 s->next=L; s=L;
考题
已知一个带头结点单链表L,在表头元素前插入新结点 *s的语句为:()A、 L=s;s->next=L;B、 s->next=L-next;L->next=s;C、 s=L;s->next=L;D、 s->next=L; s=L;
考题
—台新的eNodeB加入了网络中,并且连带着一个新的TrackingArea。为了实现这个操作,以下哪一项是必须的()A、在MME中添加eNodeB的IP地址B、在S-GW中添加TrackingAreaC、在eNodeB中添加S-GW的IP地址D、在DNS中添加TrackingArea
考题
针对Set s接口,下列哪项是正确的?() A、 s.add(2)B、 s.add(new Integer(2))C、 s.add(“2”)D、 s.add(new java.util.Date())
考题
单选题—台新的eNodeB加入了网络中,并且连带着一个新的TrackingArea。为了实现这个操作,以下哪一项是必须的()A
在MME中添加eNodeB的IP地址B
在S-GW中添加TrackingAreaC
在eNodeB中添加S-GW的IP地址D
在DNS中添加TrackingArea
考题
单选题针对Set s接口,下列哪项是正确的?()A
s.add(2)B
s.add(new Integer(2))C
s.add(“2”)D
s.add(new java.util.Date())
考题
单选题已知一个带头结点单链表L,在表头元素前插入新结点 *s的语句为:()A
L=s;s->next=L;B
s->next=L-next;L->next=s;C
s=L;s->next=L;D
s->next=L; s=L;
考题
单选题已知一个不带头结点单链表的头指针为L,则在表头元素之前插入一个新结点*s的语句为:()A
L=s; s->next=L;B
s->next=L; L=s;C
s=L; s->next=L;D
s->next=L; s=L;
考题
填空题设栈S和队列Q的初始状态为空,元素a.b.c.d.e.f依次通过栈S,一个元素出栈后即进入队列Q。若这6个元素出队列的顺序是bdcfea.则栈S的容量至少应是()。
热门标签
最新试卷