逻辑幻象


私信TA

用户名:miragelogic

访问量:25816

签 名:

稳中带皮,还有点方

等  级
排  名 265
经  验 5689
参赛次数 0
文章发表 80
年  龄 0
在职情况 学生
学  校 浙江海洋大学
专  业 机械电子工程

  自我简介:

解题思路:
贴个代码 不想写注释了


注意事项:

参考代码:

#include<stdio.h>
typedef struct node{
 int a;
 int b;
} L;
L A[1005];
int main(){
 int n;
 while(scanf("%d",&n)!=EOF){
  int i,j;
  int x[1005],y[1005];
  for(i=0;i<n;i++){
   scanf("%d %d",&A[i].a,&A[i].b);
  }
  i=0;j=0;
  int q;
  x[i]=1;y[j]=2;
  while(x[i]!=y[j]){
   for(q=0;q<n;q++){
    if(A[q].a==x[i]){
     x[++i]=A[q].b;
    }
    if(A[q].a==y[j]){
     y[++j]=A[q].b;
    }
   }
  }
  if(i==j){
   printf("You are my brother\n");
  }
  else if(i>j){
   printf("You are my elder\n");
  }
  else{
   printf("You are my younger\n");
  }
 }
 return 0;
}


 

0.0分

1 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区