16.写出以下程序段的输出结果.
来源:学生作业帮 编辑:搜搜做题作业网作业帮 分类:综合作业 时间:2024/07/18 14:34:00
16.写出以下程序段的输出结果.
class Complex extends Object {
private double x,y;
Complex(double u,double v){
x=u;
y=v;
}
double real(){
return x;
}
double imag(){
return y;
}
void plus(Complex w) {
\x05x+=w.real();
\x05y+=w.imag();
}
public String toString() {
if (y>0)
return x+" + "+y+"i";
\x05else
return x+" - "+(-y)+"i";
}
public static void main(String[] args) {
\x05 Complex c1=new Complex(2,1.5);
Complex c2=new Complex(-0.8,-3);
c1.plus(c2);
System.out.println(c1.toString());
}
}
class Complex extends Object {
private double x,y;
Complex(double u,double v){
x=u;
y=v;
}
double real(){
return x;
}
double imag(){
return y;
}
void plus(Complex w) {
\x05x+=w.real();
\x05y+=w.imag();
}
public String toString() {
if (y>0)
return x+" + "+y+"i";
\x05else
return x+" - "+(-y)+"i";
}
public static void main(String[] args) {
\x05 Complex c1=new Complex(2,1.5);
Complex c2=new Complex(-0.8,-3);
c1.plus(c2);
System.out.println(c1.toString());
}
}
运行结果:
1.2 - 1.5i
1.2 - 1.5i
写出以下程序的输出结果(答案是16,ffec,177754)
以下程序的输出结果____.
以下程序段的输出结果是int x=3;
写出下列每个程序运行后的输出结果
写出下列每个程序运行后的输出结果,
执行以下程序段后,输出结果和a的值是().int a=10; printf("%d",a++); A、11 和 10 B
编写一c++累结构程序 计算以下数据的平均值 并用函数段输出结果 10.20.4.6.11.21.55.88.8.3.6
.以下程序段的输出结果是( ).#include main( ) { char s1[10],s2[10],s3[10]
一道C语言题目,求解答以下程序的输出结果
以下程序段的输出结果是什么?: int =11; printf(''%\n'',i);
以下程序段,要求通过scanf语句给变量赋值,然后输出变量的值.
C语言题 求运行结果 下列程序段执行后的输出结果是( )