当前位置:网站首页>(practice C language every day) pointer sorting problem
(practice C language every day) pointer sorting problem
2022-07-04 02:53:00 【Yi Xiaoxia】
Pointer sorting problem
Input 10 Number , Sort the output by absolute value from large to small . Input form : Input 10 individual float The set of real Numbers Output form : Keep two significant digits after the decimal point ; The output is arranged from large to small
The following program realizes this function , Please fill in the blanks :
#include <math.h>
#include <stdio.h>
void paixu(float *p, int n)
{
int i, j;
for (i = 0; i < n - 1; i++)
{
for (j = 0; j < n - 1 - i; j++)
{
if (fabs(p[j]) < fabs(p[j + 1]))
{
float tmp;
tmp = p[j];
p[j] = p[j + 1];
p[j + 1] = tmp;
}
}
}
}
int main()
{
float f[10];
int i;
for (i = 0; i < 10; i++)
scanf("%f", &f[i]);
paixu(f, 10);
for (i = 0; i < 10; i++)
printf("%.2f ", f[i]);
return 0;
}边栏推荐
- Fudan released its first review paper on the construction and application of multimodal knowledge atlas, comprehensively describing the existing mmkg technology system and progress
- Global and Chinese market of contour projectors 2022-2028: Research Report on technology, participants, trends, market size and share
- Global and Chinese market of small batteries 2022-2028: Research Report on technology, participants, trends, market size and share
- 2006 translation
- Practical multifunctional toolbox wechat applet source code / support traffic master
- Osnabrueck University | overview of specific architectures in the field of reinforcement learning
- Pagoda SSL can't be accessed? 443 port occupied? resolvent
- Solve the problem that the tabbar navigation at the bottom of vantui does not correspond to the page (window.loading.hash)
- 2022 Guangxi provincial safety officer a certificate examination materials and Guangxi provincial safety officer a certificate simulation test questions
- 2022 examination summary of quality controller - Equipment direction - general basis (quality controller) and examination questions and analysis of quality controller - Equipment direction - general b
猜你喜欢

WP collection plug-in free WordPress collection hang up plug-in

長文綜述:大腦中的熵、自由能、對稱性和動力學

VRRP+BFD

96% of the collected traffic is prevented by bubble mart of cloud hosting

AI 助力藝術設計抄襲檢索新突破!劉芳教授團隊論文被多媒體頂級會議ACM MM錄用

Unspeakable Prometheus monitoring practice

Contest3145 - the 37th game of 2021 freshman individual training match_ 1: Origami
![[Yugong series] February 2022 attack and defense world advanced question misc-84 (MySQL)](/img/4d/4a6b76896bf81a27d036a047f68b2b.jpg)
[Yugong series] February 2022 attack and defense world advanced question misc-84 (MySQL)

Database concept and installation

LV1 previous life archives
随机推荐
中電資訊-信貸業務數字化轉型如何從星空到指尖?
Remote work guide
A. Div. 7
Network communication basic kit -- IPv4 socket structure
Global and Chinese markets of advanced X-ray inspection system (Axi) in PCB 2022-2028: Research Report on technology, participants, trends, market size and share
POSTECH | option compatible reward reverse reinforcement learning
Sword finger offer 14- I. cut rope
What are the main investment products of bond funds and what are they
Global and Chinese markets for electroencephalogram (EEG) devices 2022-2028: Research Report on technology, participants, trends, market size and share
Pagoda SSL can't be accessed? 443 port occupied? resolvent
Setting methods, usage methods and common usage scenarios of environment variables in postman
On Valentine's day, I code a programmer's exclusive Bing Dwen Dwen (including the source code for free)
How to use websocket to realize simple chat function in C #
Dare to climb here, you're not far from prison, reptile reverse actual combat case
96% of the collected traffic is prevented by bubble mart of cloud hosting
12. Gettimeofday() and time()
Amélioration de l'efficacité de la requête 10 fois! 3 solutions d'optimisation pour résoudre le problème de pagination profonde MySQL
WP collection plug-in free WordPress collection hang up plug-in
Problems and solutions of several concurrent scenarios of redis
7 * 24-hour business without interruption! Practice of applying multiple live landing in rookie villages