C语言潇洒三元运算,注意题目意思是无限完全二叉树,用不断除2直到相等即可
二叉树
http://www.nowcoder.com/questionTerminal/5b80ab166efa4551844657603227caeb
#include<stdio.h> int main() { int x,y; while(scanf("%d %d",&x,&y)!=EOF) { while(x!=y){ x>y?(x/=2):(y/=2); } printf("%d\n",y); } }
二叉树
http://www.nowcoder.com/questionTerminal/5b80ab166efa4551844657603227caeb
#include<stdio.h> int main() { int x,y; while(scanf("%d %d",&x,&y)!=EOF) { while(x!=y){ x>y?(x/=2):(y/=2); } printf("%d\n",y); } }
相关推荐