您好,欢迎来到花图问答。
搜索
您的当前位置:首页回文数及整数进制转换换序

回文数及整数进制转换换序

来源:花图问答


递归转二进制

#include

using namespace std;

void binary(int t)

{

if(t<2) {

cout<return;

}

binary(t/2);

cout<}

int main()

{

int t,i;

scanf(\"%d\

binary(t);

system(\"pause\");

}

二十六进制

#include

#include

#include

int * InitStack() {

int * top,* base;

//初始化栈

base=(int *)malloc(sizeof(int) * 50);

if(!base) {printf(\"Error!\");exit(0);}

top=base;

return top;

}

int * push(int * top,int n) {

* top=n;

top++;

return top;

}

int pop(int * top) {

//元素入栈

//取出栈顶元素

int e;

top--;

e=*top;

return e;

}

void conversion()

{

int * top, * base;

int e,N;

// int i;

top=InitStack();

base=top;

printf(\"Input the number:\\n\");

scanf(\"%d\

while(N!=0)

{

top=push(top,N%26);

N=N/26;

}

printf(\"After change,the number is:\\n\");

while(top!=base)

{

e=pop(top);

top--;

int e1=e+65;

printf(\"%c\

}

printf(\"\\n\");

}

void main()

{

conversion();

}

回文函数

char *itoa(int value,char *string)

{

int rt=0;

if(string==NULL)

return NULL;

rt=snprintf(string,MAX,\"%d\

if(rt>MAX)

return NULL;

string[rt]='\\0';

return string;

}

int huiwen_flag(int arg)

{

char c[MAX+1];

int i,j;

itoa(arg,c);

i=strlen(c);

for(j=0;j{

if(c[j]!=c[i-j-1])

return 0;

}

return 1;

}

int main()

{

int i,j,n,result=0;

for(i=100;i<999;i++)

{

for(j=i;j<999;j++)

{

n=i*j;

if( huiwen_flag(n) && n>result )

result=n;

}

}

printf(\"%d\\n\

return 0;

}

满足a=x*x+3的所有a为7的倍数的a的和是=(其中00的正整数)

#include

void main()

{

long a=sum=0;

for(long x=1;a<1019013;x++)

{

a=x*x+3;

if(a%7==0)

sum+=a;

}

printf(\"%ld\

}

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- huatuowenda.com 版权所有 湘ICP备2023022495号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务