现在进行推荐的三步如下:

1:利用数据的格式如下

此处输入图片的描述

2:编程语言采用的是Java,源代码如下:

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
94
95
96
97
98
99
100
101
102
103
104
package top10;

import java.util.*;
import java.io.*;

public class top {

public static void top(String []one,String []two,String []three){
int []one1 = new int[15688];
for(int i =0;i<15687;i++)
{
one1[i]=0;
for(int j=i;j<15688;j++)
if(one[j]==one[i])
{
one1[i]++;
}
}
for(int i =0;i<15688;i++)
for(int j=i;j<15688;j++)
if(one1[i]>one1[j])
{
String temp1;
temp1=one[i];
one[i]=one[j];
one[j]=temp1;

String temp2;
temp2=two[i];
two[i]=two[j];
two[j]=temp2;

String temp3;
temp3=three[i];
three[i]=three[j];
three[j]=temp3;
}
System.out.println("Top前十的结果为:");
System.out.println("姓名\t"+"\t推荐博客地址"+"\t\t\t\t\t\t\t\t\t\t\t"+"推荐作者博客首地址");
for(int k=1;k<=10;k++)
{
String str;
str = String.format("%s\t\t%s\t\t%s", one[k],two[k],three[k]);
System.out.println(str);
}

}

public static void list() throws IOException{
FileReader in = new FileReader("title.txt");
BufferedReader br = new BufferedReader(in);
String s1 = null;
String []one = new String[15688];
String []two = new String[15688];
String []three = new String[15688];
int i = 0,k=0,m=0,j = 1;
while((s1 = br.readLine()) != null) {
if(j%3==2)
{
two[k] = s1;
k++;
}
else if(j%3==0)
{
three[m] = s1;
m++;
}
else
{
one[i] = s1;
i++;
}
j++;
}
br.close();
in.close();
// System.out.println(j);
top(one,two,three);
}

public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub

System.out.println("+++++++++++++++++|||||||||||||||++++++++++++++++++");
System.out.println("**************欢迎使用新浪明星博客推荐系统 ***************");
System.out.println("************** 1、使用推荐功能 ***************");
System.out.println("************** 2、退出此系统,谢谢使用 ***************");
System.out.println("+++++++++++++++++|||||||||||||||++++++++++++++++++");
Scanner in = new Scanner(System.in);
while(true)
{
int i = in.nextInt();
{
switch(i)
{
case 1: list();break;
case 2:System.out.println("谢谢使用!!!");break;
default:System.out.println("请重新输入!!!");
}
}
}

}
}

3:运行的结果如图

此处输入图片的描述



打开微信扫一扫,关注公众号【搜索与推荐Wiki】