java描述艺人,新浪明星日志热门推荐(java实现)

现在进行推荐的第三步:

1:利用数据的格式如下:

27017882cb669af9750d5e1904d51415.png

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

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:运行的结果如图:

d6b5a50f03989d18c84944a02800ecb7.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值