(1)输入两个字符串做比较,如果长度相等并且出现的字母相同,则认为两个字符串相等,例如:abc 和 bca
(2)求序列 2/1 , 3/2 , 5/3 , 8/5 , 13/8 , 21/13 .....前20个序列的和
(2)求序列 2/1 , 3/2 , 5/3 , 8/5 , 13/8 , 21/13 .....前20个序列的和
要个total 全局变量可能 不好:)
if(len1 != len2)
return false;
else
{
for(int n=0;n
ch = str1.charAt(n);
for(int i=0;i
if(ch == str1.charAt(i))
c1++;
if(ch == str2.charAt(i))
c2++;
}
if(c1 == c2)
{
c1 = 0;
c2 = 0;
continue;
}
else
{
return false;
}
}
return true;
}
}
//学JAVA有段时间 代码没怎么写多少,练练。。。。:)
public class totalcount {
public float count()
{
int a=1;
int b=2;
int c;
float f2=0;
for(int i=0;i<20;i++)
{
float f1=(float)b/(float)a;
f2=f2+f1;
c=b;
b=a+b;
a=c;
}
return f2;
}
public static void main(String[] args) {
totalcount tc=new totalcount();
System.out.println(tc.count());
}
}
public class Test {
List
List
public static void main(String args[]){
String str1 = "acdbsccdddce";
String str2 = "abcdsdddccec";
Test t = new Test();
System.out.println(t.compare(str1,str2));
}
public boolean compare(String str1, String str2){
if(str1.length() != str2.length()){
return false;
}
else {
for (int i = 0; i < str1.length(); i++) {
list1.add(str1.charAt(i));
list2.add(str2.charAt(i));
// Collections.sort(list1);
// Collections.sort(list2);
}
}
return list1.containsAll(list2);
}
}