日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

c语言回文数递归,c语言问题~~~回文数!!急,拜托高人指点!!

發布時間:2023/12/2 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c语言回文数递归,c语言问题~~~回文数!!急,拜托高人指点!! 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

滿意答案

wyhjjq1

2014.01.27

采納率:53%????等級:12

已幫助:10413人

添加上滿足你補充要求的C程序:

#include

int palindrome(unsigned int x)

{

unsigned int y;

unsigned int s=0;

y=x;

while(y>0)

{

s=s*10+y%10;

y=y/10;

}

if(s==x)

return 1;

else

return 0;

}

void main()

{

printf("符合條件的N為:\n");

for(int n=1;n<=200;n++)

{

if(palindrome(n*n))

{

printf(" %-5d\n",n);

}

}

}

運行結果如下:

符合條件的N為:

1

2

3

11

22

26

101

111

121

Press any key to continue

已經上機驗證過了!!!

#include

#include

#include

int palindrome(unsigned int x) //

{

unsigned int y;

unsigned int s=0;

y=x;

while(y>0)

{

s=s*10+y%10;

y=y/10;

}

if(s==x)

return 1;

else

return 0;

}

void Reverse(unsigned char *buf,int size)

{

int i;

unsigned char temp;

if (buf==NULL || size<2) return;

for (i=0;i

{

temp=buf[i];

buf[i]=buf[size-i-1];

buf[size-i-1]=temp;

}

}

void main()

{

int count=0;

unsigned int x,temp;

char strt[10];

cout<

cin>>x;

if(palindrome(x)&&x<2147483647)

{

cout<

return;

}

int i=1,itmp;//

while(x<2147483647)//2147483647)

{

i=1;

itmp=pow(10,i);

while(x/itmp)

{

i++;

itmp=pow(10,i);

}

itoa(x,strt,10);

Reverse((unsigned char*)strt,i);

temp=atoi(strt);

x+=temp;

if(palindrome(x))

{

cout<

return;

}

}

cout<

}

00分享舉報

總結

以上是生活随笔為你收集整理的c语言回文数递归,c语言问题~~~回文数!!急,拜托高人指点!!的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。