# JAVA语法练习

SDUT - 2543 整除

import java.util.Scanner;

public class Main {

public static void main(String[] args) {
Scanner cin = new Scanner( System.in );
int n, i;
int a[] = new int [10000005];
a[1] = 0;
for(i = 2; i <= 10000000; i++)
{
if((i % 5)==0 || (i % 6)==0 || (i % 8)==0)a[i] = a[i - 1] + 1;
else a[i] = a[i - 1];
}
while(cin.hasNext())
{
n = cin.nextInt();
System.out.println(a[n]);
}
cin.close();
}

}


SDUT - 2562 相似三角形

import java.util.Scanner;

public class Main {

public static void main(String[] args) {
Scanner cin = new Scanner( System.in );
double a, b, c, d, e, f, t;
while(cin.hasNext())
{
a = cin.nextDouble();
b = cin.nextDouble();
c = cin.nextDouble();
d = cin.nextDouble();
e = cin.nextDouble();
f = cin.nextDouble();
if(a > b){t = a; a = b; b = t;}
if(b > c){t = b; b = c; c = t;}
if(a > b){t = a; a = b; b = t;}
if(d > e){t = d; d = e; e = t;}
if(e > f){t = e; e = f; f = t;}
if(d > e){t = d; d = e; e = t;}
if(a / d == b / e && a / d == c / f && a + b > c)System.out.println("YES");
else System.out.println("NO");
}
cin.close();
}

}


SDUT - 2747 洗衣服

import java.util.Scanner;

public class Main {

public static void main(String[] args) {
Scanner cin = new Scanner (System.in);
int n, m;
while(cin.hasNext())
{
n = cin.nextInt();
m = cin.nextInt();
System.out.println(n / m);
}
cin.close();
}

}


SDUT - 2252 分段函数求值

import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
Scanner cin = new Scanner (System.in);
double x, ans = 0;
while(cin.hasNext())
{
x = cin.nextDouble();
if(x > 0)ans = x * x + 1;
else if(x < 0)ans = -x;
else ans = 100;
DecimalFormat df = new DecimalFormat(".0");
System.out.println(df.format(ans));
}
cin.close();
}

}


09-09 598
09-12 286
11-19 2332
11-30 525
03-19 1万+
03-12 2175
06-02 503
03-20 401
10-19 3895
09-12 407
07-25 4518
06-12 2037
06-17 285
03-18 199
10-28 8万+