2017年网易有道秋招编程题

来源:互联网 发布:鸟哥linux基础篇 视频 编辑:程序博客网 时间:2024/06/01 12:26

第一题:12345  换成54321 后相加

#include <stdio.h>#define N  100int main(){   int n,i,k;   int sum,m=0;   scanf("%d",&n);   k=n;   if(n<1||n>100000){      return 0;   }   while (n !=0)   {      i = n %10;      m = m* 10 + i;      n = n /10;    }    sum=k+m;    printf("%d", r);}

第二题:序列,重新排序,判断可不可以满足相邻两个数相乘是4的倍数(编译未通过???)

#include <stdio.h>#define N  100000int main(){   int t,n,i,j;   int a[N];   scanf("%d",&t);   if(t<1 || t>10){       return 0;   }   for(j=0;j<t;j++){     scanf("%d",&n);     int count1=0,count2=0;     for(i=0;i<n;i++){       scanf("&d",a[i]);       if(a[i]%4==0) count1++;       else if(a[i]%2!=0) count2++;     }     if(count1>=count2-1 && n%2==1){        printf("Yes");     }else if(count1>=count2 && n%2==0){       printf("Yes");     }else{         printf("No");     }   }}



第三题:括号匹配相关题目

原创粉丝点击