当前位置:网站首页>删除所有值为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;
}边栏推荐
- P1339 [USACO09OCT]Heat Wave G
- Speed up the energy Internet of things. What can low-power Internet of things technology represented by Zeta do?
- Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
- Analysis: misunderstanding of choosing WMS warehouse management system
- [NLP] text classification still stays at Bert? Duality is too strong than learning framework
- What are the application fields of digital twins in industry?
- From functional testing to automated testing, how did I successfully transform my salary to 15K +?
- It is the most difficult to teach AI to play iron fist frame by frame. Now arcade game lovers have something
- [PHP basics] session basic knowledge, application case code and attack and defense
- [leetcode] interview question 17.08 Circus tower
猜你喜欢
![Docking Alipay process [pay in person, QR code Payment]](/img/30/665580241020ee3adb872e725f0624.jpg)
Docking Alipay process [pay in person, QR code Payment]
![[PHP basics] session basic knowledge, application case code and attack and defense](/img/f5/713d7044a693ef23e3fbb1ff9bc9f4.jpg)
[PHP basics] session basic knowledge, application case code and attack and defense

Pytest unit test framework: simple and easy to use parameterization and multiple operation modes

What is regression testing? Talk about regression testing in the eyes of Ali Test Engineers

How will the complete NFT platform work in 2022? How about its core functions and online time?

老姜的特点
![[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

Unity elementary case notes of angry birds Siki college 1-6
![[error record] configure NDK header file path in Visual Studio](/img/9f/89f68c037dcf68a31a2de064dd8471.jpg)
[error record] configure NDK header file path in Visual Studio
![[2021]NeRF in the Wild: Neural Radiance Fields for Unconstrained Photo Collections](/img/c6/3dc7d01600f6713afdbb4cf3df5238.jpg)
[2021]NeRF in the Wild: Neural Radiance Fields for Unconstrained Photo Collections
随机推荐
Regular expressions and text processors for shell programming
Vscode regular match replace console log(.*)
Collation of the most complete Chinese naturallanguageprocessing data sets, platforms and tools
Selenium library 4.5.0 keyword explanation (III)
(Video + graphics and text) introduction to machine learning series - Chapter 4 naive Bayes
Data storage - interview questions
system. Exit (0) and system exit(1)
Shell script three swordsman sed
What are the application fields of digital twins in industry?
Briefly understand the operation mode of developing NFT platform
Self study software testing. To what extent can you go out and find a job?
The frost peel off the purple dragon scale, and the xiariba people will talk about database SQL optimization and the principle of indexing (primary / secondary / clustered / non clustered)
P1629 postman delivering letter
No qualifying bean of type ‘com. netflix. discovery. AbstractDiscoveryClientOptionalArgs<?>‘ available
[leetcode] interview question 17.08 Circus tower
不得不会的Oracle数据库知识点(四)
挖财帮个人开的证券账户安全吗?是不是有套路
Alibaba test engineer with an annual salary of 500000 shares notes: a complete set of written tests of software testing
Entropy and full connection layer
8. Go implementation of string conversion integer (ATOI) and leetcode