整理音乐(SDUT 2053)

import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner reader=new Scanner(System.in);
int n=reader.nextInt();
String string[] =new String[10001];
int A[]=new int [10001];
int flag=0;
for(int i=1;i<=n;i++)
{
int m=reader.nextInt();
for(int j=1;j<=m;j++)
{
string[flag]=reader.next();
A[flag]=reader.nextInt();
flag++;
}
}
for(int i=0;i<flag-1;i++)
{
for(int j=0;j<flag-1-i;j++)
{
if(A[j]<A[j+1]||(A[j]==A[j+1]&&string[j].compareTo(string[j+1])>0))
{
int t=A[j];
A[j]=A[j+1];
A[j+1]=t;
String t1;
t1=string[j];
string[j]=string[j+1];
string[j+1]=t1;
}
}
}
for(int i=0;i<flag;i++)
{
if(i!=flag-1)
System.out.print(string[i]+" ");
else
{
System.out.println(string[i]);
}
}
reader.close(); }
}

AD  来淄博旅游(SDUT 2055)

import java.util.Scanner;
class List
{
String from[][] = new String[105][2105];
String to[][] = new String[105][2105];
int len1 = 0, len2 = 0;
int lens1[] = new int[105];
int lens2[] = new int[105];
List(int x)
{
to[0][0] = "zichuan";
to[1][0] = "linzi";
to[2][0] = "zhoucun";
to[3][0] = "boshan";
len2 = 4;
lens2[0] = lens2[1] = lens2[2] = lens2[3] = 1;
}
int fin(String a[][], int len, String x)
{
int i;
for(i = 0; i < len; i++)
{
if(a[i][0].equals(x) == true)break;
}
if(i < len)return i;
else return -1;
}
void SetData(String nam, String fro, String ti)
{
int p;
p = fin(from, len1, fro);
if(p == -1)
{
from[len1][0] = fro;
from[len1][1] = nam;
lens1[len1] = 2;
len1++;
}
else
{
from[p][lens1[p]] = nam;
lens1[p]++;
}
p = fin(to, len2, ti);
if(p != -1)
{
to[p][lens2[p]] = nam;
lens2[p]++;
}
}
void Print()
{
int i, j;
for(i = 0; i < len1; i++)
{
System.out.print(from[i][0] + " :");
for(j = 1; j < lens1[i]; j++)
{
System.out.print(" " + from[i][j]);
}
System.out.println();
}
for(i = 0; i < len2; i++)
{
System.out.print(to[i][0] + " :");
for(j = 1; j < lens2[i]; j++)
{
System.out.print(" " + to[i][j]);
}
System.out.println();
}
}
}
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int n, i, j, k;
String nam, fro, to;
List li = new List(1);
n = cin.nextInt();
nam = cin.nextLine();
for(i = 0; i < n; i++)
{
nam = cin.next();
fro = cin.next();
to = cin.next();
li.SetData(nam, fro, to);
}
li.Print();
cin.close();
}
}

最新文章

  1. hibernate(九)多对多关联
  2. Socket Programming in C#--Introduction
  3. linq 多条件查询 where 拼接+分页
  4. 如何让多个不同版本的jquery库共存
  5. 使用bootstrap建立响应式网页——通栏轮播图(carousel)
  6. 【LeetCode】118. Pascal&#39;s Triangle
  7. MYSQL数据库45道练习题
  8. AB PLC首次IP地址如何分配
  9. 菜鸡学C语言之寻根溯源
  10. 苹果笔记本安装windows正版操作系统
  11. okhttp 解析respone:
  12. linux光标操作
  13. command not found解决方案
  14. SDN期末作业验收
  15. MVC4是不是类似于html页+ashx页之间用JSON通过AJAX交换数据这种方式、?
  16. How to return NULL string
  17. jquery源码学习-初始(1)
  18. Emmet常用语法
  19. tomcat6的编译和导入myeclipse
  20. P2258 子矩阵

热门文章

  1. Effective Java 读书笔记(一):创建和销毁对象
  2. 前端开发 Vue -4promise解读2
  3. docker第二章--数据管理
  4. JS权威指南读书笔记(一)
  5. Node.js 实战(一)之—防灾备措施
  6. 如何把SAP Kyma和SAP Cloud for Customer连接起来
  7. IO模型之NIO代码及其实践详解
  8. Spring之AOP原理、代码、使用详解(XML配置方式)
  9. elasticsearch,kibana 坑之 开启外网访问
  10. 详解介绍Selenium常用API的使用--Java语言(完整版)