import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
public class Test
{
public static void main(String[] args) throws IOException
{
InputStream is = new BufferedInputStream(System.in);
byte[] be = new byte[1024];
int i ;
while(true){
while((i=is.read(be))>-1){
String s = new String(be,0,i);
String[] ss = s.split(",");
double a = Double.parseDouble(ss[0]);
double b = Double.parseDouble(ss[1]);
double a1 = Math.ceil(Math.sqrt(a));
double b1 = Math.floor(Math.sqrt(b));
int ii = (int)(b1-a1)+1;
System.out.println("有"+ii+"个平方数。");
}
}
}
}比较简陋的代码,功能实现了
import java.io.IOException;
import java.io.InputStream;
public class Test
{
public static void main(String[] args) throws IOException
{
InputStream is = new BufferedInputStream(System.in);
byte[] be = new byte[1024];
int i ;
while(true){
while((i=is.read(be))>-1){
String s = new String(be,0,i);
String[] ss = s.split(",");
double a = Double.parseDouble(ss[0]);
double b = Double.parseDouble(ss[1]);
double a1 = Math.ceil(Math.sqrt(a));
double b1 = Math.floor(Math.sqrt(b));
int ii = (int)(b1-a1)+1;
System.out.println("有"+ii+"个平方数。");
}
}
}
}比较简陋的代码,功能实现了
哥你去看下那题吧人要求输入的是多个数据而且之间用空格隔开,你这个是用逗号隔开....我的代码是能实现功能的,但是看了你的之后知道哪里不足了,类型定义错了人要求测试1-2000000000之间的数据,int小了