herrDeng網內搜尋

自訂搜尋

Ads

2011年6月9日 星期四

JAVA利用Scanner讀檔



相關後製視訊

26 則留言:

B9933070 提到...

import java.util.*;
import java.io.*;
public class fileRead {

public static void main (String[]args) throws Exception
{
File f=new File("test.txt");
Scanner input=new Scanner(f);
String tmp;
int i=0;
while (input.hasNext())
{
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if (input.hasNextInt())
System.out.println();
}
}
}

B9933106 提到...

import java.util.Scanner;
import java.io.*;
class GAP{
public static void main(String [] args)throws Exception{
File f=new File("test.txt");
Scanner input=new Scanner(f);
String tmp;
int i=0;
int a;
int sum=0;
while (input.hasNext()){
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if(input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
float b=((float)sum)/(i-1);
System.out.print("平均"+b);
}
}

B9933066 提到...

import java.util.Scanner;
import java.io.*;
class ab{
public static void main(String [] args)throws Exception{
File f=new File("test.txt");
Scanner input=new Scanner(f);
String tmp;
int i=0;
int a;
int sum=0;
while (input.hasNext()){
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if(input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
float b=((float)sum)/(i-1);
System.out.print("平均"+b);
}
}

B9933108 提到...

import java.util.*;
import java.io.*;
public class fileRead {
public static void main(String[] args) throws Exception
{
File f=new File("test.txt");
Scanner input=new Scanner(f);
String tmp;
int i=0;
int a;
float sum=0;
while (input.hasNext())
{
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if (input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
sum=sum/(i-1);
System.out.println();
System.out.print("平均= "+sum);
}
}

B9933065 提到...

import java.util.Scanner;
import java.io.*;
class dd{
public static void main(String [] args)throws Exception{
File f=new File("test.txt");
Scanner input=new Scanner(f);
String tmp;
int i=0;
int a;
float sum=0;
while (input.hasNext()){
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if(input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
sum=sum/(i-1);
System.out.println();
System.out.print("平均="+sum);
}
}

B9933100 提到...

import java.util.Scanner;
import java.io.*;
class dd{
public static void main(String [] args)throws Exception{
File f=new File("test.txt");
Scanner input=new Scanner(f);
String tmp;
int i=0;
int a;
int sum=0;
while (input.hasNext()){
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if(input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
float b=((float)sum)/(i-1);
System.out.print("全班平均是:"+b);
}
}

B9933061 提到...

import java.util.Scanner;
import java.io.*;
class dd{
public static void main(String [] args)throws Exception{
File f=new File("test.txt");
Scanner input=new Scanner(f);
String tmp;
int i=0;
int a;
int sum=0;
while (input.hasNext()){
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if(input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
float b=((float)sum)/(i-1);
System.out.print("平均"+b`);
}
}

B9933068 提到...

import java.util.Scanner;
import java.io.*;
class fileRead{
public static void main(String [] args)throws Exception{
File f=new File("test.txt");
Scanner input=new Scanner(f);
String tmp;
int i=0;
int a;
int sum=0;
while (input.hasNext()){
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if(input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
float b=((float)sum)/(i-1);
System.out.print("平均"+b);
}
}

B9933085 提到...

import java.util.*;
import java.io.*;
class fileRead {
public static void main(String[] args) throws Exception
{ File f=new File("test.txt");
Scanner input=new Scanner(f);
String tmp;
int sum=0;
int i=0;
int a;
while (input.hasNext())
{ tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if (input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
float b=((float)sum/(i-1));
System.out.print("全班平均是:"+b);
}
}

A9933058 提到...

import java.util.*;
import java.io.*;
public class U1 {

public static void main(String[]args) throws Exception
{
File f=new File("test.txt");
Scanner input=new Scanner (f);
String tmp;
int i=0;
int sum=0;
int a;
while (input.hasNext())
{
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if (input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
float b=((float)sum)/(i-1);
System.out.print("平均是:"+b);
}
}

B9933078 提到...

import java.util.Scanner;
import java.io.*;
class fileRead {
public static void main(String[] args) throws Exception{
File f=new File("test.txt");
Scanner input=new Scanner(f);
String tmp;
int i=0;
int a;
int sum=0;
while (input.hasNext()){
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if (input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
float b=((float)sum)/(i-1);
System.out.print("全班平均:"+b);
}
}

A9933059 提到...

import java.util.*;
import java.io.*;
public class U1 {

public static void main(String[]args) throws Exception
{
File f=new File("test.txt");
Scanner input=new Scanner (f);
String tmp;
int i=0;
int sum=0;
int a;
while (input.hasNext())
{
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if (input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
float b=((float)sum)/(i-1);
System.out.print("全班的平均是:"+b);
}
}

B9933078 提到...

import java.util.Scanner;
import java.io.*;
class fileRead {
public static void main(String[] args) throws Exception{
File f=new File("test.txt");
Scanner input=new Scanner(f);
String tmp;
int i=0;
int a;
int sum=0;
while (input.hasNext()){
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if (input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
float b=((float)sum)/(i-1);
System.out.print("全班平均:"+b);
}
}

A9933056 提到...

import java.util.*;
import java.io.*;
public class U1 {

public static void main(String[]args) throws Exception
{
File f=new File("test.txt");
Scanner input=new Scanner (f);
String tmp;
int i=0;
int sum=0;
int a;
while (input.hasNext())
{
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if (input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
float b=((float)sum)/(i-1);
System.out.print("全班的平均是:"+b);
}
}

B9933064 提到...

import java.util.Scanner;
import java.io.*;
class fileRead {
public static void main(String[] args) throws Exception{
File f=new File("test.txt");
Scanner input=new Scanner(f);
String tmp;
int i=0;
int a;
int sum=0;
while (input.hasNext()){
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if (input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
float b=((float)sum)/(i-1);
System.out.print("全班平均:"+b);
}
}

B9933093 提到...

import java.util.Scanner;
import java.io.*;
class fileRead {
public static void main(String[] args) throws Exception{
File f=new File("test.txt");
Scanner input=new Scanner(f);
String tmp;
int i=0;
int a;
int sum=0;
while (input.hasNext()){
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if (input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
float b=((float)sum)/(i-1);
System.out.print("全班平均:"+b);
}
}

B9933094 提到...

import java.util.Scanner;
import java.io.*;
class fileRead {
public static void main(String[] args) throws Exception{
File f=new File("test.txt");
Scanner input=new Scanner(f);
String tmp;
int i=0;
int a;
int sum=0;
while (input.hasNext()){
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if (input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
float b=((float)sum)/(i-1);
System.out.print("全班平均:"+b);
}
}

B9933110 提到...

import java.util.Scanner;
import java.io.*;
class fileRead {
public static void main(String[] args) throws Exception{
File f=new File("test.txt");
Scanner input=new Scanner(f);
String tmp;
int i=0;
int a;
int sum=0;
while (input.hasNext()){
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if (input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
float b=((float)sum)/(i-1);
System.out.print("全班平均:"+b);
}
}

B9933097 提到...

import java.util.Scanner;
import java.io.*;
class fileRead {
public static void main(String[] args) throws Exception{
File f=new File("test.txt");
Scanner input=new Scanner(f);
String tmp;
int i=0;
int a;
int sum=0;
while (input.hasNext()){
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if (input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
float b=((float)sum)/(i-1);
System.out.print("全班平均:"+b);
}
}

B9933089 提到...

import java.util.Scanner;
import java.io.*;
class fileRead {
public static void main(String[] args) throws Exception{
File f=new File("test.txt");
Scanner input=new Scanner(f);
String tmp;
int i=0;
int a;
int sum=0;
while (input.hasNext()){
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if (input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
float b=((float)sum)/(i-1);
System.out.print("全班平均:"+b);
}
}

B9933072 提到...

import java.util.Scanner;
import java.io.*;
class fileRead {
public static void main(String[] args) throws Exception{
File f=new File("test.txt");
Scanner input=new Scanner(f);
String tmp;
int i=0;
int a;
int sum=0;
while (input.hasNext()){
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if (input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
float b=((float)sum)/(i-1);
System.out.print("全班平均:"+b);
}
}

b9933087 提到...

import java.util.*;
public class Fibonacci{
public static double a(int n)
{
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2,n);
double a2=Math.pow((1-sqrt5)/2,n);
return (a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int[n+1];
f[0]=0;f[1]=1;
for(int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("a("+1+")="+a(i));
}
}
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}

b9933089 提到...

import java.util.*;
public class Fibonacci{
public static double a(int n)
{
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2,n);
double a2=Math.pow((1-sqrt5)/2,n);
return (a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int[n+1];
f[0]=0;f[1]=1;
for(int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("a("+1+")="+a(i));
}
}
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}

b9933115 提到...

import java.util.*;
public class Fibonacci{
public static double a(int n)
{
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2,n);
double a2=Math.pow((1-sqrt5)/2,n);
return (a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int[n+1];
f[0]=0;f[1]=1;
for(int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("a("+1+")="+a(i));
}
}
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}

b9933075 提到...

fileRead

import java.util.Scanner;
import java.io.*;
class fileRead {
public static void main(String[] args) throws Exception{
File f=new File("test.txt");
Scanner input=new Scanner(f);
String tmp;
int i=0;
int a;
int sum=0;
while (input.hasNext()){
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if (input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
float b=((float)sum)/(i-1);
System.out.print("全班平均:"+b);
}
}

B9933116 提到...

import java.util.Scanner;
import java.io.*;
class ab{
public static void main(String [] args)throws Exception{
File f=new File("test.txt");
Scanner input=new Scanner(f);
String tmp;
int i=0;
int a;
int sum=0;
while (input.hasNext()){
tmp=input.next();
System.out.print(i++);
System.out.print("\t"+tmp);
if(input.hasNextInt())
{
a=input.nextInt();
System.out.print("\t"+a);
sum+=a;
}
System.out.println();
}
float b=((float)sum)/(i-1);
System.out.print("平均"+b);
}
}

Related Posts Plugin for WordPress, Blogger...

熱門文章