当前位置:网站首页>删除所有值为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;
}边栏推荐
- MySQL is installed as a Windows Service
- Struct in linked list
- What is the future of software testing industry? Listen to the test veterans' answers
- Social network analysis -social network analysis
- UTS | causal reasoning random intervention based on Reinforcement Learning
- [BSP video tutorial] stm32h7 video tutorial phase 5: MDK topic, system introduction to MDK debugging, AC5, AC6 compilers, RTE development environment and the role of various configuration items (2022-
- 2022 Software Test Engineer skill list, please check
- China standard gas market prospect investment and development feasibility study report 2022-2028
- Version rollback revert don't reset better reset must be forced
- Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
猜你喜欢

Idea set class header comments

Self study software testing. To what extent can you go out and find a job?

Software testers, how can you quickly improve your testing skills? Ten minutes to teach you

Yyds dry goods inventory three JS source code interpretation - getobjectbyproperty method

MySQL winter vacation self-study 2022 12 (1)

It is worthy of "Alibaba internal software test interview notes" from beginning to end, all of which are essence

Interview script of Software Test Engineer

STM32 GPIO CSDN creative punch in
![[PHP basics] cookie basics, application case code and attack and defense](/img/7c/551b79fd5dd8a411de85c800c3a034.jpg)
[PHP basics] cookie basics, application case code and attack and defense
![Several ways to set up a blog locally [attach relevant software download links]](/img/2f/51a09d9ef71065319ed90306517854.jpg)
Several ways to set up a blog locally [attach relevant software download links]
随机推荐
1214 print diamond
[BSP video tutorial] stm32h7 video tutorial phase 5: MDK topic, system introduction to MDK debugging, AC5, AC6 compilers, RTE development environment and the role of various configuration items (2022-
Pytorch learning notes 5: model creation
Speed up the energy Internet of things. What can low-power Internet of things technology represented by Zeta do?
8. Go implementation of string conversion integer (ATOI) and leetcode
Wechat official account and synchronization assistant
Version rollback revert don't reset better reset must be forced
Joint examination of six provinces 2017
Briefly understand the operation mode of developing NFT platform
Global and Chinese markets for blood and liquid heating devices 2022-2028: Research Report on technology, participants, trends, market size and share
What does redis do? Redis often practices grammar every day
What is the Valentine's Day gift given by the operator to the product?
Optimization of for loop
What insurance products should be bought for the elderly?
Generic tips
[cloud native topic -48]:kubesphere cloud Governance - operation - overview of multi tenant concept
A dichotomy of Valentine's Day
Subgraph isomorphism -subgraph isomorphism
What is regression testing? Talk about regression testing in the eyes of Ali Test Engineers
Understanding of Radix