解题思路:看我的代码你就知道我的思路了
注意事项:处理好各种细节
参考代码:
import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int tc = sc.nextInt();
String str[] = new String [21];
while(tc != 0)
{
int n = sc.nextInt();
for(int i = 0;i < n && n <= 10;i++)
{
str[i] = sc.next();
}
for(int p = 1;p <= n - 1;p++)
{
for(int q = 0;q < n - p;q++)
{
if(str[q].compareToIgnoreCase(str[q + 1]) > 0)
{
String temp = null;
temp = str[q];
str[q] = str[q + 1];
str[q + 1] = temp;
}
}
}
for(int k = 0;k < n;k++)
{
System.out.println(str[k]);
}
tc--;
}
}
}
0.0分
0 人评分
C二级辅导-公约公倍 (C语言代码)浏览:1510 |
2004年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:506 |
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:863 |
C语言程序设计教程(第三版)课后习题6.2 (C语言代码)浏览:541 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:518 |
小O的图案 (C语言代码)浏览:915 |
小O的乘积 (C语言代码)浏览:1014 |
C语言程序设计教程(第三版)课后习题10.1 (C++代码)浏览:503 |
【出圈】 (C++代码)简单循环浏览:640 |
C语言程序设计教程(第三版)课后习题9.1 (C语言代码)浏览:546 |