DataInputStream类 如何获取当前读取位置的偏移量

file 文件 open 开始 end 关闭

没看到 API 上提到当前位page=c.page;置是如何读取的,一般流式作也不支持这个,需要知道位置的只有随机访问的 API。你尝试用 ailable() 方法得到当前有多少字符可读取到,在准备读取前和读取后比较两个值的变化或者你自己在 int count = input.read(byte[]) 后把 count 累加起来也就是当前位置了。我没试过,你测试一下可行不。

stream累加 stream计算list求和stream累加 stream计算list求和


stream累加 stream计算list求和


stream累加 stream计算list求和


ja中如何用stream将一个文档里的内容写到新的文档中

import ja.io.BufferedInputStream;

import ja.io.BufferedOutputStrbool iale;eam;

import ja.io.BufferedReader;

import ja.io.File;

import ja.io.FileInputStream;

import ja.io.FileNotFoundException;

import ja.io.FileOutputStream;

import ja.io.IOException;

import ja.io.InputStreamReader;

import ja.io.PrintWriter;

public class TestCopy {

public static void main(String[] args) throws IOException {

//原始文档路径

String old = "D:/b.txt";

//新文档路径

String newPath = "D:/a.txt";

//将原始文档通过输入流读入内存

BufferedInputStream bis = new BufferedInputStream(fis);

InputStreamReader isr = new InputStreamReader(bis);

BufferedReader br = new BufferedReader(isr);

String temp;

//通过输出流将内存中的数据写出到新的文档

FileOutputStream fos = new FileOutputStream(new File(newPath),false);//设置为false表示每次执行不累加内容到a.txt,true表示累加内容到a.txt

BufferedOutputStream bw = new BufferedOutputStream(fos);

PrintWriter pw = new PrintWriter(bw);

while((temp= br.readLine())!=null){

}if(pw!=null){

pFileInputStream fis = new FileInputStream(new File(old));w.close();

}}

}这个是将b.txt的内容写到a.txt文件里,不知你想要写的文件是什么格式的?

这相当于一个文件的过程,可以按照如下的代码进行编写:

package com.test;

import ja.io.FileInputStream;

import ja.io.FileNotFoundException;

import ja.io.FileOutputStream;

import ja.io.IOException;

public class Test {

public static void main(String[] args) {

int b = 0;

FileInputStream in = null;

FileOutputStream out = null;

try{

// 源文件路径

in = new FileInputStream("D:text.txt");

// 结果文件路径

out = new FileOutputStream("E:copytext.txt");

while((b = in.read()) != -1){

out.write(b);

}in.close();

out.close();

}catch(FileNotFoundException e1){

System.out.println("file is not found!");

System.exit(-1);

}catch(IOException e2){

System.out.println("文件错误!!");

System.exit(-1);

}System.out.println("文件成功了~~!");

}}

ja中如何用stream将一个文档里的内容写到新的文档中

FileInputStream fis = new FileInputStream(new File(old));

import ja.io.BufferedInputStream;

import ja.io.BufferedOutputStream;

import ja.io.BufferedReader;

import ja.io.File;

import ja.io.FileInputStream;

import ja.io.FileNotFoundException;

import ja.io.FileOutputStream;

import ja.io.IOException;

import ja.io.Is4.ShowNum();nputStreamReader;

import ja.io.PrintWriter;

public class TestCopy {

public static void main(String[] args) throws IOException {

//原始文档路径

String old = "D:/b.txt";

//新文档路径

String newPath = "D:/a.txt";

//将原始文档通过输入流读入内存

BufferedInputStream bis = new BufferedInputStream(fis);

InputStreamReader isr = new InputStreamReader(bis);

BufferedReader br = new BufferedReader(isr);

String temp;

//通过输出流将内存中的数据写出到新的文档

FileOutputStream fos = new FileOutputStream(new File(newPath),false);//设置为false表示每次执行不累加内容到a.txt,true表示累加内容到a.txt

BufferedOutputStream bw = new BufferedOutputStream(fos);

PrintWriter pw = new PrintWriter(bw);

while((temp= br.readLine())!=null){

}if(pw!=null){

pw.close();

}}

}这个是将b.txt的内容写到a.txt文件里,不知你想要写的文件是什么格式的?

这相当于一个文件的过程,可以按照如下的代码进行编写:

package com.test;

import ja.io.FileInputStream;

import ja.io.FileNotFoundException;

import ja.io.FileOutputStream;

import ja.io.IOException;

public class Test {

public static void main(String[] args) {

int b = 0;

FileInputStream in = null;

FileOutputStream out = null;

try{

// 源文件路径

in = new FileInputStream("D:text.txt");

// 结果文件路径

out = new FileOutputStream("E:copytext.txt");

while((b = in.read()) != -1){

out.write(b);

}in.close();

out.close();

}catch(FileNotFoundException e1){

System.out.println("file is not found!");

System.exit(-1);

}catch(IOException e2){

System.out.println("文件错误!!");

System.exit(-1);

}System.out.println("文件成功了~~!");

}}

ja编程:用户从键盘上输入10个数,分别统计正数、负数、零的个数、平均值、累加和。

}oprator = (CStudent& student)

这种题目也只有我们这些小菜鸟会理你了。素数楼上已经帮你写好了。我写了标题那个。有点多,不过挺好理解的我觉得。试过了能运行。

{public:

package myTest;

import ja.io.BufferedReader;

import ja.io.IOException;

import ja.io.InputStream;

import ja.io.InputStreamReader;

import ja.util.ArrayList;

class test

{public static void main(String[] args) throws IOException

{System.out.println("请输入您需要统计的数据,逗号隔开");

BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));

String[] st = buf.readLine().trim().split(",");

ArrayList itive=new ArrayList();

ArrayList negtive=new ArrayList();

int sum=0;

double g=0;

int zeroNum=0;

for(int i=0;i

int number=Integer.parseInt(st[i]);

if(number>0){

itive.add(number);

}if(number<0){

negtive.add(number);

}if(number==0){

zeroNum++;

}sum+=number;

}g=sum1.0/st.length;

System.out.println("正数为:");

for (int i=0;i

System.out.print(itive.get(i)+"t");

}System.out.println();

System.out.println("负数为:");

for (int i=0;i

System.out.print(negtive.get(i)+"t");

}System.out.println();

System.out.println("零的个数为:"+zeroNum);

System.out.println("和为:"+sum);

System.out.println("平均数为:"+g);

}}

判断素数

boolean isSushu(int num){

boolean bl=true;

for(int i=2;i

if(num%i==0){ bl=false;}

}return bl;

快考试了,一道C++的题,跪求高手!4:30就考试了,急啊!

完全按原题要求编写的程序如下,dev-c++和vs2005下编译通过。

#include

using namespace std;

const double PI=3.1415926;

class CPerson{//定义抽象类

static int m_sCount;//定义静态累加器

virtual double Getdata()=0;//声明纯虚函数

CPe}double Getdata()//重新定义基类中的纯虚函数rson()

}~CPerson()

{m_sCount--;

}void static ShowNum(){//定义静态成员函数

cout<

}};

int CPerson::m_sCount = 0;//静态数据成员初始化

class CStudent:public CPerson{//公用继承

CStudent(double Cost=0.0):cost(Cost){};

CStudent(CStudent &s)//定义拷贝构造函数

{cost=s.cost;

}void operator=(CStudent &s)//重载赋值运算符

{cost=s.cost;

{return cost;

}protected:

double cost;

};

class CTeacher:public CPerson{

CTeacher(double Page=0.0):page(Page){};

CTeacher(CTeacher &c)//定义拷贝构造函数

{page=c.page;

}void operator=(CTeacher &c)//重载赋值运算符

{page=c.page;

{return page;

}protected:

double page;

};

class CStudentTeacher: public CStudent, public CTeacher{//多重继承

CStudentTeacher(double Cost, double Page,int Age):CStudent(Cost),CTeacher(Page),age(Age){};

CStudentTeacher(CStudentTeacher &c)//定义拷贝构造函数

{age=c.age;

cost=c.cost;

}void operator=(CStudentTeacher &c)//重载赋值运算符

{age=c.age;

cost=c.cost;

}void Showdata()

{cout<<"Age and Cost and Page per month of new person is "<

}private:

int age;

};

int main()

{CStudent s1(600.0);

s1.ShowNum();

cout<<"Cost per month of new person is "<

CStudent s2(s1);

s2.ShowNum();

cout<<"Cost per month of new person is "<

CStudent s3=s1;

s3.ShowNum();

cout<<"Cost per month of new person is "<

CTeacher c1(1500.0);

c1.ShowNum();

cout<<"Page per month of new person is "<

CTeacher c2(c1);

c2.ShowNum();

cout<<"Page per month of new person is "<

CTeacher c3=c1;

c3.ShowNum();

cout<<"Page per month of new person is "<

CStudentTeacher s4(500.0,1000.0,25);

CPerson::m_sCount--;

s4.Showdata();

CStudentTeacher s5(s4);

CPerson::m_sCount--;

s5.ShowNum();

s5.Showdata();

CStudentTeacher s6=s4;

CPerson::m_sCount--;

s6.ShowNum();

s6.Showdata();

("pause");

return 0;

}

#include

#include

using namespace std;

class CPerson

CPerson(){m_sCount++;}

static int ShowNum();

void get();

void put();

protected:

string name;

string ;

int age;

static int m_sCount;

};

int CPerson::m_sCount=0;

int CPerson::ShowNum(){return m_sCount;}

void CPerson::get(){cin>>name>>>>age;return;}

void CPerson::put(){cout<

void gets(){cin>>number;return;}

void puts(){cout<<" "<

protected:

string number; //学号

};

class CTeacher: virtual public CPerson

void gett(){cin>>subject;return;}

void putt(){cout<<" "<

protected:

string subject; //教师所教科目

};

class CStudentTeacher:public CStudent,public CTeacher

CStudentTeacher():CPerson(){}

friend istream& operator >>(istream&,CStudentTeacher&);

friend ostream& operator <<(ostream&,CStudentTeacher&);

};

istream& operator >>(istream& input,CStudentTeacher& obj)

{ obj.get();obj.gets();obj.gett(); return input;}

ostream& operator <<(ostream& output,CStudentTeacher& obj)

{ obj.put();obj.puts();obj.putt(); return output;}

int main()

{CStudentTeacher obj;

cin>>obj;

cout<

cout<

return 0;

}

#define PI 3.14

#include

//抽象类

class CShape

virtual float GetArea() =0 ;//纯虚函数

static int m_sCount ;

CShape()

{++m_sCount ;

}static int ShowNum()

{return m_sCount ;

}};

class CSquare:public CShape

{private:

float m_Length;

float GetArea()

{return m_Length m_Height ;

}}

class CCircle:public CShape

{public float GetArea()

{return PI r r ;

}}

写不动了

参见

class CPerson

CString name;

CString age;

static int m_sCount;

CPerson()

{m_sCount = 0;

}static int ShowNum()

{return m_sCount;

}};

class CStudent : public CPerson

CStudent()

{CPerson::m_sCount++;

}CStudent(CStudent& student)

{this.name = student.name;

this.age = student.age;

{this.name = student.name;

this.age = student.age;

}};

class CTeacher :public CPerson

CTeacher()

{CPerson::m_sCount++;

}CTeacher(CTeacher& teacher)

{this.name = teacher.name;

this.age = teacher.age;

}};

class CStudentTeacher : public CStudent,public CTeacher

{//自己根据需要再写写吧

}

功能不全,转载过来的。凑合着看吧,不要太紧张,好运!

定义一个人员类CPerson,包括数据成员:姓名、编号、{operator << (out,dynamic_cast (p) );性别和用于输入、输出的成员函数。在此基础上派生出学生类CStudent(增加成绩)和教师类CTeacher(增加教龄),并实现对学生和教师信息的输入输出。

#include

using std::cout;

using std::cin;

using std::endl;

using std::ostream;

using std::istream;

class CPerson

{private:

enum { MaxSize = 10 };

char name[MaxSize];

char ID[MaxSize];

friend istream & operator >> (istream &in, CPerson &p);

friend ostream & operator << (ostream &out,const CPerson &p);

};

ostream & operator << (ostream &out,const CPerson &p)

{cout << "name:" << p.name << "t" << "id:" << p.ID << "t" << ":"

<< (p.iale?"male":"female") ;

return out;

}istream & operator >> (istream &in, CPerson &p)

{cout << "Please input the namen" ;

in.getline(p.name,CPerson::MaxSize);

cout << "Please input the idn" ;

cout << "Please input the [male:1 female:0]:n" ;

in >> p.iale ;

return in;

}class CStudent:public CPerson

{private:

double score;

friend istream & operator >> (istream &in, CStudent &p);

friend ostream & operator << (ostream &out,const CStudent &p);

};

istream & operator >> (istream &in, CStudent &p)

{operator >> (in, dynamic_cast (p) );

cout << "Please input the scoren";

in >> p.score;

return in;

}ostream & operator << (ostream &out,const CStudent &p)

out << "tthe score is:" << p.score;

return out;

}class CTeacher:public CPerson

{private:

int age;

friend istream & operator >> (istream &in, CTeacher &p);

friend ostream & operator << (ostream &out,const CTeacher &p);

};

istream & operator >> (istream &in, CTeacher &p)

{operator >> (in, dynamic_cast (p) );

cout << "Please input the agen";

in >> p.age;

return in;

}ostream & operator << (ostream &out,const CTeacher &p)

out << "tthe age is:" << p.age;

return out;

}void flushcin(istream &in) //清空输入流中的字符

{in.clear();

while ( in.get() != 'n' )

continue;

}int main()

{CPerson a;

cin >> a;

cout << a << endl;

flushcin(cin);

CStudent b;

cin >> b;

flushcin(cin);

CTeacher c;

cin >> c;

cout << c << endl;

return 0;

}

想不出就别想了。闭上眼休息一下吧。考前不能这么紧张的。估计这种题在这么短的时间里想在这里找到很难。

编程序常用英语单词是什么

in.getline(p.ID,CPerson::MaxSize);

编程序常用英语单词部分:

on

1、Compile:编绎

一、编程:设计具备逻辑流动作用的一种“可控体系”【注:编程不一定是针对计算机程序而言的,针对具备逻辑计算力的体系,都可以算编程。】

二、编程是编写程序的中文简称,就是让计算机代为解决某个问题,对某个计算体系规定一定的运算方式,使计算体系按照该计算方式运行,并最终得到相应结果的过程。

三、为了使计算机能够理解人的意图,人类就必须将需解决的问题的思路、方法和手段通过计算机能够理解的形式告诉计算机,使得计算机能够根据人的指令一步一步去工作,完成某种特定的任务。这种人和计算体系之间交流的过程就是编程。

参考资料:

1、Compile:编绎2、Run:运行3、Class:类4、Object:对象5、System:系统6、out:输出7、print:打印8、line:行9、variable:变量10、type:类型11、static:静态的12、array:数组13、parameter:参数14、mod:方法15、function:函数16、public:公有的17、default:默认18、get:得到19、private:私有的20、import:导入21、set:设置22、package:包23、access:访问24、protected:受保护的25、void:无(返回类型)26、operation:作运算27、member-variable:成员变量28、member-function:成员函数29、extends:继承 base class:基类 parent class:父类30、intece:接口 child class:子类 super class:超类31、overload:重载 abstract:抽象 exception:异常32、implements:实现 Runtime:运行时33、derived class:派生类34、override:重写覆盖35、final:最终的不能改变的

编程说白了, 就是你用计算机的语言将你要表达的东西翻译给计算机....关键在于你该怎样设计你要表达的东西...

只会做翻译, 就相当于只会干体力活...

对于设计,只要你有良好的数学思维能力, 那就肯定没问题...

常用的语句那是肯定要记住的,这是最基础的, 而且光记住还不行, 还要搞懂每条语句的功能, 用法.....

工具到不需要什么, 只要一个编译器 , 如turboc2.0

win-tc 之类的, 有了编译器 你可以先自己尝试编一些简单的程序,.<

汗,谁说的.

编程里面是有英文没有错,但是他们都是固定了的,你多练就可以了.晕,什么叫他的英语成绩想下来都下来.汗.这句话,得离谱,编程里面的英语和你们学英语的数量占多少.编程里面的英语来来去去也只有那几十个关键字还有一些代码,再加上你们学的英语应该是日常用语单词都可以上千.难道你们考试是考计算机英语,而且是来来去去就考编程里面的那几十个单词,而计算机编程里面用的是计算机英语.根本就不同.

楼主他那在吹,你信他个P呀.就是为了你让嫉妒<

变成程序常用的英语单词是marker马赛

我建议你看一下原版的教程,比如Thinking in Ja

看一本下来,然后你记录那些你不会的单词

自己查电脑!

开几个主流的开发软件一个一个翻译。完了就不多了

苹果长在树上用"on"还是"in",为什么?

public:

in,因为树木丰茂,所以看起来是“在里面”。类似的有in the bed

用on 因为苹果是长在树上的,长在树上的用on,而不长在树上的用in,例如,鸟,鸡等

是用on,不是用in

凡事本来长在树上的,都是on ;不是长在树上的,如鸟等,才用in。错不了,错了我负责。

交你一个很好的记忆“东西长在树上是用on还是in”的方法吧:苹果是整体看起来是圆圆的,所以用on,因为on中有个O像苹果一样圆圆的,所以要用ocout << b << endl;n。

树构成了一个空间,进入它就用“in”。 而作为构成空间的一部分(如苹果树上的苹果)用on。

苹果是一个果子,结在树枝上的,所以用on,并没有长到树的内里面去,所以不用in.

如果说一只猫在树上,为什么就用in了呢?想象一下,一只猫,在树上,肯定是在茂密的树叶从中,远看就是猫淹没在树丛里面了的感觉,鸟也一样,因此都用in.

树上长的,属于数的用on.

落在树上用的(如鸟等)用in

on,凡事本来长在树上的,都是on .外来物用in

树上长的,属于数的用on.

落在树上用的(如鸟等)用in

快考试了,一道C++的题,跪求高手!4:30就考试了,急啊!

扩展资料

完全按原题要求编写的程序如下,dev-c++和vs2005下编译通过。

#include

using namespace std;

const double PI=3.1415926;

class CPerson{//定义抽象类

static int m_sCount;//定义静态累加器

virtual double Getdata()=0;//声明纯虚函数

CPerson()

}~CPerson()

{m_sCount--;

}void static ShowNum(){//定义静态成员函数

cout<

}};

int CPerson::m_sCount = 0;//静态数据成员初始化

class CStudent:public CPerson{//公用继承

CStudent(double Cost=0.0):cost(Cost){};

CStudent(CStudent &s)//定义拷贝构造函数

{cost=s.cost;

}void operator=(CStudent &s)//重载赋值运算符

{cost=s.cost;

{return cost;

}protected:

double cost;

};

class CTeacher:public CPerson{

CTeacher(double Page=0.0):page(Page){};

CTeacher(CTeacher &c)//定义拷贝构造函数

{page=c.page;

}void operator=(CTeacher &c)//重载赋值运算符

{page=c.page;

{return page;

}protected:

double page;

};

class CStudentTeacher: public CStudent, public CTeacher{//多重继承

CStudentTeacher(double Cost, double Page,int Age):CStudent(Cost),CTeacher(Page),age(Age){};

CStudentTeacher(CStudentTeacher &c)//定义拷贝构造函数

{age=c.age;

cost=c.cost;

}void operator=(CStudentTeacher &c)//重载赋值运算符

{age=c.age;

cost=c.cost;

}void Showdata()

{cout<<"Age and Cost and Page per month of new person is "<

}private:

int age;

};

int main()

{CStudent s1(600.0);

s1.ShowNum();

cout<<"Cost per month of new person is "<

CStudent s2(s1);

s2.ShowNum();

cout<<"Cost per month of new person is "<

CStudent s3=s1;

s3.ShowNum();

cout<<"Cost per month of new person is "<

CTeacher c1(1500.0);

c1.ShowNum();

cout<<"Page per month of new person is "<

CTeacher c2(c1);

c2.ShowNum();

cout<<"Page per month of new person is "<

CTeacher c3=c1;

c3.ShowNum();

cout<<"Page per month of new person is "<

CStudentTeacher s4(500.0,1000.0,25);

CPerson::m_sCount--;

s4.Showdata();

CStudentTeacher s5(s4);

CPerson::m_sCount--;

s5.ShowNum();

s5.Showdata();

CStudentTeacher s6=s4;

CPerson::m_sCount--;

s6.ShowNum();

s6.Showdata();

("pause");

return 0;

}

#include

#include

using namespace std;

class CPerson

CPerson(){m_sCount++;}

static int ShowNum();

void get();

void put();

protected:

string name;

string ;

int age;

static int m_sCount;

};

int CPerson::m_sCount=0;

int CPerson::ShowNum(){return m_sCount;}

void CPerson::get(){cin>>name>>>>age;return;}

void CPerson::put(){cout<

void gets(){cin>>number;return;}

void puts(){cout<<" "<

protected:

string number; //学号

};

class CTeacher: virtual public CPerson

void gett(){cin>>subject;return;}

void putt(){cout<<" "<

protected:

string subject; //教师所教科目

};

class CStudentTeacher:public CStudent,public CTeacher

CStudentTeacher():CPerson(){}

friend istream& operator >>(istream&,CStudentTeacher&);

friend ostream& operator <<(ostream&,CStudentTeacher&);

};

istream& operator >>(istream& input,CStudentTeacher& obj)

{ obj.get();obj.gets();obj.gett(); return input;}

ostream& operator <<(ostream& output,CStudentTeacher& obj)

{ obj.put();obj.puts();obj.putt(); return output;}

int main()

{CStudentTeacher obj;

cin>>obj;

cout<

cout<

return 0;

}

#define PI 3.14

#include

//抽象类

class CShape

virtual float GetArea() =0 ;//纯虚函数

static int m_sCount ;

CShape()

{++m_sCount ;

}static int ShowNum()

{return m_sCount ;

}};

class CSquare:public CShape

{private:

float m_Length;

float GetArea()

{return m_Length m_Height ;

}}

class CCircle:public CShape

{public float GetArea()

{return PI r r ;

}}

写不动了

参见

class CPerson

CString name;

CString age;

static int m_sCount;

CPerson()

{m_sCount = 0;

}static int ShowNum()

{return m_sCount;

}};

class CStudent : public CPerson

CStudent(pw.println(temp);)

{CPerson::m_sCount++;

}CStudent(CStudent& student)

{this.name = student.name;

this.age = student.age;

{this.name = student.name;

this.age = student.age;

}};

class CTeacher :public CPerson

CTeacher()

{CPerson::m_sCount++;

}CTeacher(CTeacher& teacher)

{this.name = teacher.name;

this.age = teacher.age;

}};

class CStudentTeacher : public CStudent,public CTeacher

{//自己根据需要再写写吧

}

功能不全,转载过来的。凑合着看吧,不要太紧张,好运!

定义一个人员类CPerson,包括数据成员:姓名、编号、性别和用于输入、输出的成员函数。在此基础上派生出学生类CStudent(增加成绩)和教师类CTeacher(增加教龄),并实现对学生和教师信息的输入输出。

#include

using std::cout;

using std::cin;

using std::endl;

using std::ostream;

using std::istream;

class CPerson

{private:

enum { MaxSize = 10 };

char name[MaxSize];

char ID[MaxSize];

friend istream & operator >> (istream &in, CPerson &p);

friend ostream & operator << (ostream &out,const CPerson &p);

};

ostream & operator << (ostream &out,const CPerson &p)

{cout << "name:" << p.name << "t" << "id:" << p.ID << "t" << ":"

<< (p.iale?"male":"female") ;

return out;

}istream & operator >> (istream &in, CPerson &p)

{cout << "Please input the namen" ;

in.getline(p.name,CPerson::MaxSize);

cout << "Please input the idn" ;

cout << "Please input the [male:1 female:0]:n" ;

in >> p.iale ;

return in;

}class CStudent:public CPerson

{private:

double score;

friend istream & operator >> (istream &in, CStudent &p);

friend ostream & operator << (ostream &out,const CStudent &p);

};

istream & operator >> (istream &in, CStudent &p)

{operator >> (in, dynamic_cast (p) );

cout << "Please input the scoren";

in >> p.score;

return in;

}ostream & operator << (ostream &out,const CStudent &p)

out << "tthe score is:" << p.score;

return out;

}class CTeacher:public CPerson

{private:

int age;

friend istream & operator >> (istream &in, CTeacher &p);

friend ostream & operator << (ostream &out,const CTeacher &p);

};

istream & operator >> (istream &in, CTeacher &p)

{operator >> (in, dynamic_cast (p) );

cout << "Please input the agen";

in >> p.age;

return in;

}ostream & operator << (ostream &out,const CTeacher &p)

out << "tthe age is:" << p.age;

return out;

}void flushcin(istream &in) //清空输入流中的字符

{in.clear();

while ( in.get() != 'n' )

continue;

}int main()

{CPerson a;

cin >> a;

cout << a << endl;

flushcin(cin);

CStudent b;

cin >> b;

flushcin(cin);

CTeacher c;

cin >> c;

cout << c << endl;

return 0;

}

想不出就别想了。闭上眼休息一下吧。考前不能这么紧张的。估计这种题在这么短的时间里想在这里找到很难。

ja编程:用户从键盘上输入10个数,分别统计正数、负数、零的个数、平均值、累加和。

on

这种题目也只有我们这些小菜鸟会理你了。素数楼上已经帮你写好了。我写了标题那个。有点多,不过挺好理解的我觉得。试过了能运行。

package myTest;

import ja.io.BufferedReader;

import ja.io.IOException;

import ja.io.InputStream;

import ja.io.InputStreamReader;

import ja.util.ArrayList;

class test

{public static void main(String[] args) throws IOException

{System.out.println("请输入您需要统计的数据,逗号隔开");

BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));

String[] st = buf.readLine().trim().split(",");

ArrayList itive=new ArrayList();

ArrayList negtive=new ArrayList();

int sum=0;

double g=0;

int zeroNum=0;

for(int i=0;i

int number=Integer.parseInt(st[i]);

if(number>0){

itive.add(number);

}if(number<0){

negtive.add(number);

}if(number==0){

zeroNum++;

}sum+=number;

}g=sum1.0/st.length;

System.out.println("正数为:");

for (int i=0;i

System.out.print(itive.get(i)+"t");

}System.out.println();

System.out.println("负数为:");

for (int i=0;i

System.out.print(negtive.get(i)+"t");

}System.out.println();

System.out.prfloat m_Height ;intln("零的个数为:"+zeroNum);

System.out.println("和为:"+sum);

System.out.println("平均数为:"+g);

}}

判断素数

boolean isSushu(int num){

boolean bl=true;

for(int i=2;i

if(num%i==0){ bl=false;}

}return bl;