当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
lua初学
Behind iFLYTEK's translation machine stealing the spotlight, cross-language communication has entered a new era
keepalived:主备配置
「业务架构」TAGAF建模:业务服务/信息图
JS高级 之 使用 Iterator - Generator
「数据战略」结果驱动的企业数据策略:组织和治理
makefile 杂项
反射效率为什么低?
CSDN21天学习挑战赛——多态(05)
单例模式基类
ESP8266 教程2 — 烧录AT固件
消息队列概述
LeetCode Algorithm 1472. 设计浏览器历史记录
傅立叶级数与傅里叶变换
武功修炼:招式
14道高频手写JS面试题及答案,巩固你的JS基础
web项目访问引用jar内部的静态资源
LeetCode Algorithm 1721. 交换链表中的节点
解决ASP.NET Core在Task中使用IServiceProvider的问题
08 【Props 组件事件】