public class Test {
/**
* time :2017-9-24
* author:wangqian
*/
public static void main(String[] args) {
String[] str1 = {"ar","nt","ey","su","yi"};
String[] str2 = {"cff","jgg"};
ReverseSort.Sort(str1);
ReverseSort.Sort(str2);
System.out.print("排序字符串1:");
for(int i = 0;i<str1.length;i++)
{
System.out.print(" "+str1[i]);
}
System.out.println();
System.out.print("排序字符串2:");
for(int j = 0;j<str2.length;j++)
{
System.out.print(" "+str2[j]);
}
System.out.println();
System.out.print("排序合并两个字符串:");
s1.Reverse(str1, str2);
int []str3 = {2,5,3,1};
int []str4 = {4,7,1};
IntegerIntersection.Intersection(str3, str4);
float []str3 = {1.0f,4.5f,6.7f,3.5f};
float []str4 = {1.1f,3.5f,6.8f};
FloatSum.Float(str3, str4);
}
}
public class ReverseSort {
public static void Sort(String str[])
{
String tmp;
for(int i= 0;i<str.length;i++)
{
for(int j=0;j<str.length-i-1;j++)
{
if(str[j].compareTo(str[j+1])<0)
{
tmp = str[j+1];
str[j+1]=str[j];
str[j]=tmp;
}
}
}
}
public static void Reverse(String str1[],String str2[])
{
String []tmp = new String[str1.length+str2.length];
int i=0;
int k=0;
while(i<str1.length)
{
tmp[k]=str1[i];
i++;
k++;
}
int j= 0;
while(j<str2.length)
{
tmp[k]= str2[j];
j++;
k++;
}
Sort(tmp);
for(int n= 0;n<tmp.length;n++)
{
System.out.print(" "+tmp[n]);
}
}
}
public class IntegerIntersection {
public int []str1;
public int []str2;
public void Intersection(int[] str1,int[] str2)
{
for(int i=0;i<str1.length;i++)
{
for(int j = 0;j<str2.length;j++)
{
if(str1[i]==str2[j])
{
System.out.println(str1[i]);
}
}
}
}
}
public class FloatSum {
public static void Float(float str1[],float str2[])
{
float []str3 = new float[str1.length+str2.length];
{
int i=0;
int k=0;
while(i<str1.length)
{
str3[k]=str1[i];
i++;
k++;
}
int j= 0;
while(j<str2.length)
{
str3[k]= str2[j];
j++;
k++;
}
for(int n= 0;n<str3.length;n++)
{
System.out.print(" "+str3[n]);
}
}
}
}