參考代碼:
創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供尖草坪網(wǎng)站建設(shè)、尖草坪做網(wǎng)站、尖草坪網(wǎng)站設(shè)計(jì)、尖草坪網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)與制作、尖草坪企業(yè)網(wǎng)站模板建站服務(wù),10年尖草坪做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。
//******************************************************************************
//
逆序輸出
//******************************************************************************
#includestdio.h
#include
math.h
int
main()
{
long
x,
a,
b,
i=0;
double
c=0;
//pow的用法:
double
pow(
double
base,
double
exp
);
//
clrscr();
//
i
=
0;
//
c
=
0;
printf("please
input
a
score!\n");
scanf("%ld",
x);
a
=
x;
b
=
x;
do
{
a
=
a
/
10;
i++;
}
while(a
!=
0);
printf("the
wei
of
the
number
is\t%ld\n",
i);
i--;
//因?yàn)橛胮ow,i需減一
do
{
a=
b
%
10;
//用a來保存求余
c
+=
a
*
pow(10,
i);
b
=
b
/
10;
i--;
}
while(i
=0);
printf("the
answer
is
%.0lf\n",
c);
}
//******************************************************************************
//因?yàn)橹皇堑剐蜉敵觯圆槐剞D(zhuǎn)換,直接求余輸出即可,代碼如下
//******************************************************************************
#includestdio.h
int
main()
{
int
n;
while(scanf("%d",n)!=EOF)
//多項(xiàng)測(cè)試
Ctrl
+
Z
結(jié)束輸入
{
while(n)
{
printf("%d",n%10);
n/=10;
}
printf("\n");
}
}
//******************************************************************************
//逆序輸出
再來個(gè)比較簡(jiǎn)潔的
//******************************************************************************
#includestdio.h
int
main()
{
int
n;
//要求n為正整數(shù)
for(scanf("%d",
n);
n
printf("%d",
n
%
10);
n
/=
10);
}
你好這個(gè)是字符串的逆序輸出string a="hello world";int i=a.length;int j;for(j=i;j0;j--){printf("%c",a[j]); } 這個(gè)是數(shù)組的逆序int i;int a[10]={1,2,3,4,5,6,7,8,9,10};for(i=10;i0;i++)printf("%d",a[i]); 希望對(duì)你有幫助
輸入三位數(shù)比如564
scanf("%d",c);
int d = c%10*100+(c/10)%10+c%100;
printf("%",d)
C++繼承了C語言的大部分特性,因此保留了“程序總是從main函數(shù)開始執(zhí)行,且總是默認(rèn)從main函數(shù)的return語句或結(jié)尾處結(jié)束運(yùn)行”這一傳統(tǒng),但是要注意,C++中的main函數(shù)要想作為程序執(zhí)行的出入口,必須寫在全局(Global)范圍。
擴(kuò)展資料:
計(jì)算一個(gè)排列的逆序數(shù)的直接方法是逐個(gè)枚舉逆序,同時(shí)統(tǒng)計(jì)個(gè)數(shù)。例如在序列 { 2, 4, 3, 1 } 中,逆序依次為 (2,1),(4,3),(4,1),(3,1),因此該序列的逆序數(shù)為 4。Visual Basic?6.0 編寫的示例使用的就是直接計(jì)數(shù)的方法,函數(shù) NiXushu 返回一個(gè)字符串的逆序數(shù)。
參考資料來源:百度百科-逆序數(shù)
從最后一個(gè)元素,逆向遍歷到數(shù)組的0元素,逐一輸出即可實(shí)現(xiàn)。
1、創(chuàng)建數(shù)組;
2、輸入值;
3、逆序遍歷輸出數(shù)組。
代碼:int?main(){ int?a[10]; int?i;
for(i?=?0;?i??10;?i?++)
scanf("%d",a+i);
for(i?=?9;?i?=?0;?i?--)
printf("%d?",?a[i]);}
擴(kuò)展資料:
將一個(gè)數(shù)組逆序輸出。
1、程序分析:用第一個(gè)與最后一個(gè)交換。
2、程序源代碼:
#define N 5
main()
{ int a[N]={9,6,5,4,1},i,temp;
printf(" original array: ");
for(i=0;i printf("%4d",a[i]);
for(i=0;i {temp=a[i];
a[i]=a[N-i-1];
a[N-i-1]=temp;
}
printf(" sorted array: ");
for(i=0;i printf("%4d",a[i]);}
參考資料:百度百科 c語言
本文名稱:c語言函數(shù)輸出逆序數(shù) c語言逆序數(shù)
瀏覽路徑:http://chinadenli.net/article36/hgdspg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、網(wǎng)站策劃、Google、網(wǎng)站導(dǎo)航、自適應(yīng)網(wǎng)站、外貿(mào)網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)