当前位置:网站首页>删除所有值为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;
}边栏推荐
- NLP pre training technology development
- 国元证券开户是真的安全可靠吗
- Make small tip
- It is forbidden to splice SQL in code
- Regular expressions and text processors for shell programming
- The upload experience version of uniapp wechat applet enters the blank page for the first time, and the page data can be seen only after it is refreshed again
- It is the most difficult to teach AI to play iron fist frame by frame. Now arcade game lovers have something
- 功能:编写函数fun求s=1^k+2^k +3^k + ......+N^k的值, (1的K次方到N的K次方的累加和)。
- China standard gas market prospect investment and development feasibility study report 2022-2028
- Struct in linked list
猜你喜欢

Joint examination of six provinces 2017

Eight year test old bird, some suggestions for 1-3 year programmers

From functional testing to automated testing, how did I successfully transform my salary to 15K +?

Data mining vs Machine Learning: what is the difference between them? Which is more suitable for you to learn

Similarities and differences of text similarity between Jaccard and cosine

功能:将主函数中输入的字符串反序存放。例如:输入字符串“abcdefg”,则应输出“gfedcba”。

Idea a method for starting multiple instances of a service

NLP pre training technology development

Collation of the most complete Chinese naturallanguageprocessing data sets, platforms and tools
![[Mongodb] 2. Use mongodb --------- use compass](/img/d5/0eb7dd4c407fbf2e9ba1b175f5424d.jpg)
[Mongodb] 2. Use mongodb --------- use compass
随机推荐
Alibaba test engineer with an annual salary of 500000 shares notes: a complete set of written tests of software testing
Makefile judge custom variables
UTS | causal reasoning random intervention based on Reinforcement Learning
Pytest unit test framework: simple and easy to use parameterization and multiple operation modes
What insurance products should be bought for the elderly?
8. Go implementation of string conversion integer (ATOI) and leetcode
It is forbidden to splice SQL in code
CSP window
Make small tip
Data storage - interview questions
Regular expressions and text processors for shell programming
Axure resources and prototype tool Axure RP 9 download
Is the securities account opened by Caicai for individuals safe? Is there a routine
Report on the construction and development mode and investment mode of sponge cities in China 2022-2028
Iclr2022: how does AI recognize "things I haven't seen"?
[PHP basics] session basic knowledge, application case code and attack and defense
Solution to the impact of Remote Code Execution Vulnerability of log4j2 component on December 9, 2021
【leetcode】374. Guess the size of the number
BBS forum recommendation
[error record] configure NDK header file path in Visual Studio (three header file paths of NDK | ASM header file path selection related to CPU architecture)