import javaioBufferedWriter;
import javaioFile;
import javaioFileWriter;
import javaioIOException;
interface Shape{
double area() throws Exception;
void write(Object content);
}
abstract class AbstractShape implements Shape {
@Override
public void write(Object content) {
// TODO Auto-generated method stub
FileWriter fw = null;
BufferedWriter bw = null;
File file = null;
try {
file = new File("resulttxt");
if (!fileexists())
filecreateNewFile();
fw = new FileWriter(file);
bw = new BufferedWriter(fw);
bwwrite(""+content);
bwclose();
} catch (Exception e) {
eprintStackTrace();
} finally {
try {
if (fw != null)
fwclose();
if(bw != null)
bwclose();
} catch (IOException e) {
// TODO Auto-generated catch block
eprintStackTrace();
}
}
}
}
class Cricle extends AbstractShape {
private double r;
public Cricle() {
super();
}
public Cricle(double r) {
super();
thisr = r;
}
public double getR() {
return r;
}
public void setR(double r) {
thisr = r;
}
@Override
public double area() throws Exception {
// TODO Auto-generated method stub
if (r <= 0) {
throw new Exception("半径不能小于0");
}
return MathPI Mathpow(r, 2);
}
}
class Rectangle extends AbstractShape {
private double w;
private double h;
public Rectangle() {
super();
}
public Rectangle(double w, double h) {
super();
thisw = w;
thish = h;
}
public double getW() {
return w;
}
public void setW(double w) {
thisw = w;
}
public double getH() {
return h;
}
public void setH(double h) {
thish = h;
}
@Override
public double area() throws Exception {
// TODO Auto-generated method stub
if (w <= 0 || h <= 0) {
throw new Exception("不能构成矩形");
}
return w h;
}
}
class Triangle extends AbstractShape {
private double x;
private double y;
private double z;
public Triangle() {
super();
}
public Triangle(double x, double y, double z) {
super();
thisx = x;
thisy = y;
thisz = z;
}
public double getX() {
return x;
}
public void setX(double x) {
thisx = x;
}
public double getY() {
return y;
}
public void setY(double y) {
thisy = y;
}
public double getZ() {
return z;
}
public void setZ(double z) {
thisz = z;
}
@Override
public double area() throws Exception {
// TODO Auto-generated method stub
if (x + y <= z || x + z <= y || y + z <= x) {
throw new Exception("不能构成三角形");
}
double p = (x + y + z) / 2;
return Mathsqrt(p (p - x) (p - y) (p - z));
}
}
//测试
public class Test{
public static void main(String[] args) {
Shape shape = new Triangle(3, 4, 5);
try {
double area = shapearea();
shapewrite(area);
Systemoutprintln("area: " + area);
} catch (Exception e) {
eprintStackTrace();
}
}
}
不是广告,我在用这个小程序刷题。做为一款免费的刷题小程序还算不错。虽然有些答案,可能不对(小于1%吧),并且有时候卡顿。
现在改版了,颜色不再像原来过于艳丽刺眼,并且题库扩充增加了计算机一级还有Python。做完一个题,解析下面还有一些精选的励志或是富有哲理的句子,这也是新增的一个特别的地方。
(这么大编辑中不可以剪辑编辑吗?我想把它缩小一点或是裁剪一些)
来欣赏一下新版的精选语句。
别把生活当游戏,谁游戏人生,生活就会惩罚谁。
接下来,练习错题集,把较容易些的改正过的易错题,删除。还是不理解,又错的添加到收藏。我原以为从错题集添加到收藏,就可以在错题集里删除,可是试了之后才知道,一做删除 *** 作,收藏夹里的也没有了。
以上就是关于请大神用Python编写一个做题程序,如何读取一个question(题目).txt和answer(答案).txt,并提示对,错全部的内容,包括:请大神用Python编写一个做题程序,如何读取一个question(题目).txt和answer(答案).txt,并提示对,错、小程序答题系统能用代码快答吗、如何看待程序员面试让上机做编程题,这样的公司多吗等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)