c语言 command

来源:百度知道 编辑:UC知道 时间:2024/05/22 04:36:53
怎么样可以显示这样的输出,下面是个例子:
Command? ins 7
Command? ins 5
Command? ins 4
Command? pri
4 5 7
Command? ins 1
Command?Del 1
Command? pri
1 5 7
command? ins 5
Command? pri
1 5 5 7
Command? occ 5
2
Command? occ -7
0
Command? ins 5
Command? ins 7
Command? pri
1 5 5 5 7 7
Command? cnt
6
Command? cdv
3
Command? ran -1 10
6
Command? ran 5 7
5
Command? end

定义一个有序数组,保存数据

Command?是预先print上

判断?后面跟的字符串进行对应操作
ins按序插入
pri打印出数组内容
Del删除第n个数
occ查找后面跟的参数个数
cnt查询数组元素个数
cdv查询非重复数组元素个数
ran不太清楚-再想想
end退出程序