2018年11月6日深信服校招笔试题编程题A题

2018年11月6日深信服校招笔试题编程题A题:
#include<iostream>
#define MAX 10^9
using namespace std;
char str[MAX];
char str1[MAX][MAX];
char * int2str(int num){     int n=0,i;     for(num;num>0;num=num/10)         n=n*10+num%10;     for (i=0;n>0;n=n/10)         str[i++]=n%10+48;     str[i]=0;     return str;
}
int main(){     int T;     int parm[MAX][4];     int temp1,temp2,temp3,temp4,temp5;     cin>>T;     for(int i=0;i<T;i++){         for(int j=0;j<4;j++){             cin>>parm[i][j];         }     }     for(i=0;i<T;i++){         temp1=parm[i][0];         temp2=parm[i][1];         temp3=parm[i][2];         temp4=parm[i][3];         if(temp4<=3){             cout<<parm[i][temp4]<<endl;         }         else{             while(strlen(str1[i])<temp4-3){                 temp5=temp1+temp2+temp3;                 temp1=temp2;                 temp2=temp3;                 temp3=temp5;                 strcat(str1[i],int2str(temp3));             }             cout<<str1[i];             cout<<str1[i][temp4-4]<<endl;         }     }     return 0;
}
#include<string>


#深信服##校招#
全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务