当前位置:网站首页>ZZULIOJ 1116 Delete elements [delete]
ZZULIOJ 1116 Delete elements [delete]
2022-08-10 10:04:00 【An Ran_】
1116: delete element
Time limit: 1 Sec Memory limit: 128 MB
Submitted: 20393 Solved: 12008
[status] [discussion boarda>] [Submit] [Submit by:admin]Title description
Input an incrementally ordered integer array A with n elements, delete the element with subscript i to keep it in continuous order.Note that valid subscripts start at 0.The following two functions are defined to implement delete element operation and array output operation respectively.
void del(int a[], int n, int i); /*Delete the element with index i in the array a*/
void PrintArr(int a[], int n); /*OutputThe first n elements of array a */Enter
The input is divided into three lines, the first line is an integer n (n<10), the second line is n integers, and the third line is the subscript i of the element to be deleted, i>=0.
Output
Output the array elements after deleting the element with subscript i, and separate the data with spaces.
Sample input Copy
61 3 5 7 9 113Sample output Copy
1 3 5 9 11Tips
Please note that when the array has only one element and is deleted, the array is empty, and there should be no output at this time.A common mistake is to output the first element or a carriage return in this case.
#include void del(int a[], int n, int i);void PrintArr(int a[], int n);int main(){int n;int i,j;int a[20];scanf("%d",&n);for(i=0;i Key analysis of problem solving:
(1) Delete operation
Locate the position to be deleted and move forward in turn (for loop implementation)
Additional: Insert operation: locate the position to be inserted and move backward
边栏推荐
猜你喜欢
随机推荐
LeetCode Algorithm 1472. 设计浏览器历史记录
CSDN 21 Days Learning Challenge - Polymorphism (05)
Static关键字及应用,继承的概念
dedecms支持Word内容一键上传
属性动画QPropertyAnimation
定时任务Quartz
The web project accesses static resources inside the reference jar
细说Redis监控和告警
mysql千万级别数据库优化
重学冒泡排序
IDEA中xml文件头报错:URI is not registered (Settings | Languages & Frameworks | Schemas and DTDs)
SQL中的字符串截取函数
LiveGBS操作日志页面快速的筛选上级平台的调用记录直播观看录像回看等操作
LCD DRM驱动框架分析一
数据库事务
态势丨黑客侵扰加剧,靶场为网络安全架设“防御盾”
Fourier series and Fourier transform
【软考 系统架构设计师】系统可靠性分析与设计① 系统可靠性分析
对话陈赐靓:哪吒要让高端产品大众化
阻塞队列与线程池原理









