当前位置:网站首页>(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;
}
边栏推荐
- Unity knapsack system (code to center and exchange items)
- Node solves cross domain problems
- STM32 key content
- 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
- 2022 registration examination for safety production management personnel of fireworks and firecracker production units and examination skills for safety production management personnel of fireworks an
- Global and Chinese market of box seals 2022-2028: Research Report on technology, participants, trends, market size and share
- 150 ppt! The most complete "fair perception machine learning and data mining" tutorial, Dr. AIST Toshihiro kamishima, Japan
- Johnson–Lindenstrauss Lemma
- [UE4] parse JSON string
- Push technology practice | master these two tuning skills to speed up tidb performance a thousand times!
猜你喜欢
The first spring of the new year | a full set of property management application templates are presented, and Bi construction is "out of the box"
LV1 previous life archives
The "message withdrawal" of a push message push, one click traceless message withdrawal makes the operation no longer difficult
Unity controls the selection of the previous and next characters
Advanced learning of MySQL -- Application -- storage engine
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
中電資訊-信貸業務數字化轉型如何從星空到指尖?
Yyds dry goods inventory hand-in-hand teach you the development of Tiktok series video batch Downloader
(column 23) typical C language problem: find the minimum common multiple and maximum common divisor of two numbers. (two solutions)
Crawler practice website image batch download
随机推荐
PMP daily three questions (February 14, 2022)
WordPress collection WordPress hang up collection plug-in
Short math guide for latex by Michael downs
Record a problem that soft deletion fails due to warehouse level error
Www 2022 | taxoenrich: self supervised taxonomy complemented by Structural Semantics
Redis transaction
Solve the problem that the tabbar navigation at the bottom of vantui does not correspond to the page (window.loading.hash)
Global and Chinese market for travel wheelchairs 2022-2028: Research Report on technology, participants, trends, market size and share
A. Div. 7
Tsinghua University product: penalty gradient norm improves generalization of deep learning model
Unity writes a character controller. The mouse controls the screen to shake and the mouse controls the shooting
C # learning notes: structure of CS documents
2022 Guangxi provincial safety officer a certificate examination materials and Guangxi provincial safety officer a certificate simulation test questions
FRP intranet penetration
Network byte order
PTA tiantisai l1-079 tiantisai's kindness (20 points) detailed explanation
Buuctf QR code
POSTECH | option compatible reward reverse reinforcement learning
STM32 key content
Format character%* s