package work4;
import java.util.Scanner;
public class Dwork1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
System.out.println("请输入一个整数");
int number=sc.nextInt();
if(number%3==0&&number%5==0&&number%7==0)
{
System.out.println("该数可以被3,5,7整除");
}else if(number%3==0&&number%5==0)
{
System.out.println("该数可以被3,5整除");
}else if(number%3==0&&number%7==0)
{
System.out.println("该数可以被3,7整除");
}else if(number%5==0&&number%7==0)
{
System.out.println("该数可以被5,7整除");
}if(number%3==0||number%5==0||number%7==0)
{
System.out.println("该数只可以被3,5,7中一个整除");
}
else {
System.out.println("该数不能被3,5,7中任何一个整除");
}
}
}
package work4;
public class Dwork2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int a[]= {1,9,3,7,4,2,5,0,6,8};
System.out.print("排序前a[]=");
for(int n:a) {
System.out.print(n);
}
for(int i=0;i<a.length;i++)
{ for(int j=i+1;j<a.length;j++)
{
if(a[j]<a[i])
{
int t=a[j];
a[j]=a[i];
a[i]=t;
}
}
}
System.out.println("排序后a[]=");
for(int n:a) {
System.out.print(n);
}
}
}
package work4;
import java.util.Scanner;
public class Dwork3 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int index=0,count=0;
Scanner sc=new Scanner(System.in);
System.out.println("请输入S1");
String s1=sc.next();
System.out.println("请输入S2");
String s2=sc.next();
index=s1.indexOf(s2);
while((index=s1.indexOf(s2))!=-1)
{
s1=s1.substring(index+s2.length());
count++;
}
if(count==0)
{
System.out.println("s1中包含0个s2");
}else
{
System.out.println("s1中包含"+count+"个s2");
}
}
}