#include stdio.h
創(chuàng)新互聯(lián)長期為1000+客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺(tái),與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為冀州企業(yè)提供專業(yè)的成都網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、外貿(mào)營銷網(wǎng)站建設(shè),冀州網(wǎng)站改版等技術(shù)服務(wù)。擁有10多年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。
#define N 20
void f (int a[],int n)
{
int i,j,temp;
for(j=0;jn-1;j++)
for(i=0;in-j-1;i++)
if(a[i]a[i+1])
{
temp=a[i];
a[i]=a[i+1];
a[i+1]=temp;
}
printf("%d人成績排序輸出的結(jié)果為:",n);
for(i=0;in;i++)
printf("%d ",a[i]);
getchar();
getchar();
}
void main()
{
int n,i,math[N];
n=0;
printf("輸入人數(shù):");
scanf("%d",n);
printf("輸入%d人的成績:",n);
for(i=0;in;i++)
scanf("%d",math[i]);
f(math,n);
}
【〇貳〇壹〇】
一些數(shù)學(xué)計(jì)算的公式的具體實(shí)現(xiàn)是放在math.h里,具體有:
double sin (double x); x的正弦值
double cos (double x); x的余弦值
double tan (double x); x的正切值
double asin (double x); 結(jié)果介于[-PI/2, PI/2],x值域?yàn)閇-1,1]
double acos (double x); 結(jié)果介于[0, PI],x值域?yàn)閇-1,1]
double atan (double x); 反正切(主值), 結(jié)果介于[-PI/2, PI/2]
double atan2 (double y, double x); 反正切(整圓值), 結(jié)果介于[-PI, PI]
double sinh (double x); x的雙曲正弦值
double cosh (double x); x的雙曲余弦值
double tanh (double x); x的雙曲正切值
double exp (double x); 冪函數(shù)e^x
double pow (double x, double y); x^y,如果x=0且y=0,或者x0且y不是整型數(shù),將產(chǎn)生定義域錯(cuò)誤
double sqrt (double x); x的平方根,其中x=0
double log (double x); 以e為底的對(duì)數(shù),自然對(duì)數(shù),x0
double log10 (double x); 以10為底的對(duì)數(shù),x0
double ceil (double x); 取上整
double floor (double x); 取下整
double fabs (double x); x的絕對(duì)值
double frexp (double x, int *exp); 標(biāo)準(zhǔn)化浮點(diǎn)數(shù), x = f * 2^exp, 已知x求f, exp ( x介于[0.5, 1] )并返回f值
double ldexp (double x, int exp); 與frexp相反, 已知x, exp求x*2^exp
double modf (double x, double *ip); 將參數(shù)的整數(shù)部分通過指針回傳, 返回小數(shù)部分,整數(shù)部分保存在*ip中
double fmod (double x, double y); 返回兩參數(shù)相除x/y的余數(shù),符號(hào)與x相同。如果y為0,則結(jié)果與具體的額實(shí)現(xiàn)有關(guān)
老師教的東西沒學(xué)會(huì)呀,要用指針
void atoz(int *a,int *b,int *c) //將輸入的數(shù)據(jù)按由小到大排列
再試一下或者
void atoz(int a,int b,int c) //將輸入的數(shù)據(jù)按由小到大排列
知道數(shù)組為什么能行嗎?應(yīng)為數(shù)組x[]其實(shí)就是一個(gè)指針或者理解為地址
#includestdio.h
#include
math.h
//從鍵盤上輸入10個(gè)整數(shù),要求用插入法實(shí)現(xiàn)對(duì)它們進(jìn)行降序排列。
//(主函數(shù)完成輸入輸出功能,排序用函數(shù)sort()來實(shí)現(xiàn))。
void
sort(int
a[],int
n)
{
int
i,j,temp;
for(i=0;in-1;i++)
{
temp=a[i+1];
j=i;
while(j-1tempa[j])
{
a[j+1]=a[j];
j--;
}
a[j+1]=temp;
}
}
int
main()
{
int
i,a[10]={0};
printf("請(qǐng)輸入10個(gè)數(shù)據(jù):\n");
for(i=0;i10;i++)
scanf("%d",a[i]);
for(i=0;i10;i++)
printf("%d\t",a[i]);
sort(a,10);
for(i=0;i10;i++)
printf("%d\t",a[i]);
return
0;
}
網(wǎng)頁名稱:c語言math排序函數(shù) C語言整數(shù)排序
本文URL:http://www.rwnh.cn/article22/hhgjcc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、網(wǎng)站導(dǎo)航、標(biāo)簽優(yōu)化、定制開發(fā)、服務(wù)器托管、虛擬主機(jī)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)