b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

c多线程面试题同步_高级java多线程面试题_多线程面试题(28)

电脑杂谈  发布时间:2017-03-08 11:17:18  来源:网络整理

printf("Input two numbers:/n");

while( (2!=scanf("%d%*c%d",&n,&m)) )

{

fflush(stdin);

printf("Input error! Again:/n");

}

combination(n,m);

printf("/n");

}

void combination(int m,int n)

{

int temp=m;

push(temp);

while(1)

{

if(1==temp)

{

if(pop(&temp)&&stack[0]==n) //当栈底元素弹出&&为可能取的最小值,循环退出

break;

}

else if( push(--temp))

{

printf("%d%d%d ",stack[0],stack[1],stack[2]);//§ä¨ì¤@

pop(&temp);

}

}

}

int push(int i)

{

stack[++top]=i;

if(top<2)

return 0;

else

return 1;

}

int pop(int *i)

{

*i=stack[top--];

if(top>=0)

return 0;

else

return 1;

}1、用指针的方法,将字符串“ABCD1234efgh”前后对调显示

#include <stdio.h>

#include <string.h>

#include <dos.h>

int main()

{

char str[] = "ABCD1234efgh";

int length = strlen(str);

char * p1 = str;

char * p2 = str + length - 1;

while(p1 < p2)

{

char c = *p1;

*p1 = *p2;

*p2 = c;

++p1;

--p2;

}

printf("str now is %s/n",str);

system("pause");

return 0;

}

2、有一分数序列:1/2,1/4,1/6,1/8……,用函数调用的方法,求此数列前20项的和

#include <stdio.h>

double getValue()

{

double result = 0;

int i = 2;

while(i < 42)

{

result += 1.0 / i;//一定要使用1.0做除数,不能用1,否则结果将自动转化成整数,即0.000000

i += 2;

}

return result;

}

int main()

{

printf("result is %f/n", getValue());

system("pause");

return 0;

}]]>

</Content>

<PostDateTime>2006-4-17 10:17:34</PostDateTime>

</Reply>

<Reply>

<PostUserNickName>白日 做梦!</PostUserNickName>

<rank>一级(初级)</rank>

<ranknum>user1</ranknum>

<credit>100</credit>


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-36439-28.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    • 李洁
      李洁

      你回学校跪个键盘我看哈

    热点图片
    拼命载入中...