设为首页 加入收藏

TOP

数据结构顺序表的“增删改查”功能实现(二)
2017-08-02 10:22:15 】 浏览:10101
Tags:数据结构 顺序 删改 功能 实现
k= int(raw_input()) a.remove(a[k-1]) print "the list is ",a,' now' p,q =map(int,raw_input("enter the position and number you want to modify:\n").split()) a[p-1] = q print "the list is ",a,' now' print 'enter the number you want to find in the list' n = int(raw_input()) if n in a: for i in range(len(a)): if a[i] == n: print "%d is the %dth element in the list"% (n,i+1),a else: print 'Not found!\n'

输出展示:

E:\Python27\python.exe D:/python/python算法/b.py
Enter the list:
1 2 3 4
The list is:

[1, 2, 3, 4]
The length of the list is: 4
Enter the position and number you want to add: 
1 2
the list is  [2, 1, 2, 3, 4]  now
enter the position you want to remove in the list
2
the list is  [2, 2, 3, 4]  now
enter the position and number you want to modify:
1 5
the list is  [5, 2, 3, 4]  now
enter the number you want to find in the list
4
4 is the 4th element in the list [5, 2, 3, 4]

Process finished with exit code 0

收工!

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇While循环以及 do while 循环介绍 下一篇C语言宏定义##连接符和#符的使用

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目