当前位置:网站首页>删除所有值为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;
}边栏推荐
- A dichotomy of Valentine's Day
- URL (data:image/png; Base64, ivborw0k... Use case
- HR disgusted interview behavior
- Kubedl hostnetwork: accelerating the efficiency of distributed training communication
- Analysis: misunderstanding of choosing WMS warehouse management system
- Is user authentication really simple
- STM32 key light
- Social network analysis -social network analysis
- UTS | causal reasoning random intervention based on Reinforcement Learning
- [PHP basics] session basic knowledge, application case code and attack and defense
猜你喜欢

Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?

BBS forum recommendation

Entropy and full connection layer

打印菱形图案
![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]

Yyds dry goods inventory three JS source code interpretation - getobjectbyproperty method
![[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!](/img/28/fc05f2e8d53cf81fd061c799090022.jpg)
[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!

Briefly understand the operation mode of developing NFT platform
![P3371 [template] single source shortest path (weakened version)](/img/c5/bcb22e1ea573253005e56ebbd73bb7.jpg)
P3371 [template] single source shortest path (weakened version)

Generic
随机推荐
Global and Chinese market of breast cancer imaging 2022-2028: Research Report on technology, participants, trends, market size and share
Introduction to thread pool
It is forbidden to splice SQL in code
Social network analysis -social network analysis
Eight year test old bird, some suggestions for 1-3 year programmers
On the day when 28K joined Huawei testing post, I cried: everything I have done in these five months is worth it
2022 Software Test Engineer skill list, please check
2022 system integration project management engineer examination knowledge points: software development model
【leetcode】300. Longest increasing subsequence (dynamic programming, dichotomy)
NLP pre training technology development
Data mining vs Machine Learning: what is the difference between them? Which is more suitable for you to learn
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
Is it really possible that the monthly salary is 3K and the monthly salary is 15K?
How to trade spot gold safely?
Wechat official account and synchronization assistant
What are the application fields of digital twins in industry?
Pair
How will the complete NFT platform work in 2022? How about its core functions and online time?
功能:将主函数中输入的字符串反序存放。例如:输入字符串“abcdefg”,则应输出“gfedcba”。
Correlation analysis summary