当前位置:网站首页>(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;
}
边栏推荐
- PMP daily three questions (February 14, 2022)
- 查詢效率提昇10倍!3種優化方案,幫你解决MySQL深分頁問題
- [untitled]
- 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
- Contest3145 - the 37th game of 2021 freshman individual training match_ 1: Origami
- Optimization theory: definition of convex function + generalized convex function
- A. Div. 7
- Global and Chinese market of handheld melanoma scanners 2022-2028: Research Report on technology, participants, trends, market size and share
- Examination question bank of constructor decoration direction post skills (constructor) and examination data of constructor decoration direction post skills (constructor) in 2022
- [Yugong series] February 2022 attack and defense world advanced question misc-84 (MySQL)
猜你喜欢
Buuctf QR code
MySQL advanced SQL statement (1)
A brief talk on professional modeler: the prospect and professional development of 3D game modeling industry in China
Record a problem that soft deletion fails due to warehouse level error
Zblog collection plug-in does not need authorization to stay away from the cracked version of zblog
What is cloud primordial?
[Valentine's Day confession code] - Valentine's Day is approaching, and more than 10 romantic love effects are given to the one you love
Node solves cross domain problems
Imperial cms7.5 imitation "D9 download station" software application download website source code
中電資訊-信貸業務數字化轉型如何從星空到指尖?
随机推荐
2022 examination summary of quality controller - Equipment direction - general basis (quality controller) and examination questions and analysis of quality controller - Equipment direction - general b
LV1 previous life archives
Site favorites
查詢效率提昇10倍!3種優化方案,幫你解决MySQL深分頁問題
Redis transaction
Servlet simple verification code generation
Unity writes a character controller. The mouse controls the screen to shake and the mouse controls the shooting
中電資訊-信貸業務數字化轉型如何從星空到指尖?
The 37 year old programmer was laid off, and he didn't find a job for 120 days. He had no choice but to go to a small company. As a result, he was confused
Global and Chinese market of small batteries 2022-2028: Research Report on technology, participants, trends, market size and share
Kiss number + close contact problem
Experience summary of the 12th Blue Bridge Cup (written for the first time)
Examination question bank of constructor decoration direction post skills (constructor) and examination data of constructor decoration direction post skills (constructor) in 2022
Measurement fitting based on Halcon learning [4] measure_ arc. Hdev routine
Advanced learning of MySQL -- Application -- storage engine
Problems and solutions of several concurrent scenarios of redis
Unspeakable Prometheus monitoring practice
Create real-time video chat in unity3d
Johnson–Lindenstrauss Lemma
LV1 Roche limit