360公司 2016校园招聘在线笔试编程题

第一题

将考研分数分类

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <cstdio>

int main(){
int t, a, b, c, d, s;
scanf("%d", &t);
while(t--){
scanf("%d %d %d %d", &a, &b, &c, &d);
s = a + b + c + d;
if(a < 60 || b <60 || c < 90 || d < 90 || s < 310)
printf("Fail\n");
else if(s < 350)
printf("Zifei\n");
else
printf("Gongfei\n");
}
return 0;
}

第二题

将一个数分解质因数,再用电子表上数字的表示方法表示成各质因数按从小到大顺序相乘的形式。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*************************************************************************
> File Name: 2.cpp
> Author: minyu
> Mail: wmy0831988@163.com
> Created Time: Tue 15 Sep 2015 08:05:17 PM CST
************************************************************************/


#include <cstdio>
#include <string>
using namespace std;


#define maxn 30
int a[maxn]; //an
int b[maxn*4]; //*
int n, count_a, count_b; //count_an(a) count_b : b


string num[10][5]={
{" - ", "| |", " ", "| |", " - "}, //0
{" ", " |", " ", " |", " "}, //1
{" - ", " |", " - ", "| ", " - "}, //2
{" - ", " |", " - ", " |", " - "}, //3
{" ", "| |", " - ", " |", " "}, //4


{" - ", "| ", " - ", " |", " - "}, //5
{" - ", "| ", " - ", "| |", " - "}, //6
{" - ", " |", " ", " |", " "}, //7
{" - ", "| |", " - ", "| |", " - "}, //8
{" - ", "| |", " - ", " |", " - "}, //9
};


void fenjie(int n){
count_a = 0;
while(n > 1){
for(int i = 2; i <= n; i++){
if(n % i == 0){
n /= i;
a[count_a++] = i;
break;
}
}
}
}


void print(){
count_b = 0;
for(int i = 0; i < count_a; i++){
int t = a[i]; bool flag = 0;
for(int base = 100000; base > 0; base /=10){
if(flag == 0 && t / base > 0) {
flag = 1;
b[count_b++] = t / base;
t %= base;
}
else if(flag == 1){
b[count_b++] = t /base;
t %= base;
}
}
if(i != count_a - 1)
b[count_b++] = 10;
}

for(int i = 0; i < 5; i++){
for(int j = 0; j < count_b; j++){
int nu = b[j];
if(nu == 10){
if(i == 2) printf("*");
else printf(" ");
}
else{
printf("%c", num[nu][i][0]);
printf("%c", num[nu][i][1]);
printf("%c", num[nu][i][2]);
}
}
printf("\n");
}
}


int main(){
while(~scanf("%d", &n)){
fenjie(n);
print();
}
return 0;
}