当前位置:网站首页>删除所有值为y的元素。数组元素中的值和y的值由主函数通过键盘输入。
删除所有值为y的元素。数组元素中的值和y的值由主函数通过键盘输入。
2022-07-04 00:34:00 【CTGU-Yoghurt】
题目:
删除所有值为y的元素。数组元素中的值和y的值由
主函数通过键盘输入。
代码详解:
#include <stdio.h>
#include<conio.h>
#include<stdio.h>
#define M 20
void fun(int bb[], int* n, int y)
{
/**********Program**********/
for (int i = 0; i < *n;)
{
if (bb[i] == y) {
for (int j = i; j < *n; j++)
{
bb[j] = bb[j + 1];
}
(* n)--;//注:--的优先级在*的前面,所以用括号展开
}
else i++;
}
/********** End **********/
}
int main()
{
int aa[M], n, y, k;
printf("\nPlease enter n:"); scanf("%d", &n);
printf("\nEnter %d positive number:\n", n);
for (k = 0; k < n; k++) scanf("%d", &aa[k]);
printf("The original data is:\n");
for (k = 0; k < n; k++) printf("%5d", aa[k]);
printf("\nEnter a number to deletede:"); scanf("%d", &y);
fun(aa, &n, y);
printf("The data after deleted %d:\n", y);
for (k = 0; k < n; k++) printf("%4d", aa[k]);
printf("\n");
return 0;
}
边栏推荐
- Global and Chinese markets for instant saliva testing devices 2022-2028: Research Report on technology, participants, trends, market size and share
- Eight year test old bird, some suggestions for 1-3 year programmers
- What is the GPM scheduler for go?
- Smart fan system based on stm32f407
- [PHP basics] cookie basics, application case code and attack and defense
- It is worthy of "Alibaba internal software test interview notes" from beginning to end, all of which are essence
- What are the application fields of digital twins in industry?
- Regular expressions and text processors for shell programming
- Data mining vs Machine Learning: what is the difference between them? Which is more suitable for you to learn
- 不得不会的Oracle数据库知识点(一)
猜你喜欢
A Kuan food rushed to the Shenzhen Stock Exchange: with annual sales of 1.1 billion, Hillhouse and Maotai CCB are shareholders
功能:将主函数中输入的字符串反序存放。例如:输入字符串“abcdefg”,则应输出“gfedcba”。
Yyds dry goods inventory three JS source code interpretation - getobjectbyproperty method
The FISCO bcos console calls the contract and reports an error does not exist
What is the future of software testing industry? Listen to the test veterans' answers
(Video + graphics and text) introduction to machine learning series - Chapter 4 naive Bayes
[PHP basics] session basic knowledge, application case code and attack and defense
Qtcharts notes (V) scatter diagram qscatterseries
Pytorch learning notes 5: model creation
Analysis: misunderstanding of choosing WMS warehouse management system
随机推荐
不得不会的Oracle数据库知识点(四)
想请教一下,十大劵商如何开户?在线开户是安全么?
Selenium library 4.5.0 keyword explanation (II)
Investment demand and income forecast report of China's building ceramics industry, 2022-2028
Unity elementary case notes of angry birds Siki college 1-6
HR disgusted interview behavior
Shell script three swordsman sed
Introduction to thread pool
[GNN] hard core! This paper combs the classical graph network model
(Introduction to database system | Wang Shan) Chapter V database integrity: Exercises
Why use get/set instead of exposing properties
[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!
MySQL is installed as a Windows Service
What are the application fields of digital twins in industry?
Docking Alipay process [pay in person, QR code Payment]
【leetcode】300. Longest increasing subsequence (dynamic programming, dichotomy)
Report on prospects and future investment recommendations of China's assisted reproductive industry, 2022-2028 Edition
Recommendation of knowledge base management system
Double efficiency. Six easy-to-use pychar plug-ins are recommended
CSP window