摘要:
//task2#include <iostream> #include <fstream> #include <vector> #include "Person.h" int main() { using namespace std; vector<Person> phone_book; Perso 阅读全文
摘要:
实验二 同名覆盖原则:由于基类和派生类的函数名一样,系统无法按原则(原则:先基类,然后对象,最后派生类)调用,就覆盖了。 二元作用域分辨符:可以通过派生类名和作用域分辨符来访问派生类中的同名成员。 类型兼容原则:类型兼容原则是指在需要基类对象的任何地方,都可以使用公有派生类的对象来替代。 通过公有继 阅读全文
摘要:
任务四: //Vector_int.h #ifndef LAB3_VECTOR_INT_H #define LAB3_VECTOR_INT_H #include "iostream" using namespace std; class Vector_int { private: int n; in 阅读全文
摘要:
(因为编码问题,代码中选择英文代替中文) 实验任务5 源代码: //info,h #ifndef INC_27_LAB1_INFO_H #define INC_27_LAB1_INFO_H #include "string" #include "iostream" using namespace s 阅读全文
摘要:
实验任务3 //task3.cpp #include "Complex.h" #include <iostream> int main() { using namespace std; Complex c1(3, -4); const Complex c2(4.5); Complex c3(c1); 阅读全文
摘要:
任务一(已验证) 任务二(已验证) 任务三: 运行程序,屏幕上出现正确结果 在当前文件夹可以找到文本文件file3.dat 可见用记事本打开文件,可以正确显示内容信息,直观可读。(因为创建的是文本数据文件,而非其他格式) 任务四: 子任务1: 运行程序,屏幕上正确输出了排序后的学生信息。 在当前路径 阅读全文
摘要:
任务一 // P280例8.15 // 对教材上的程序作了微调整,把输出学生信息单独编写成一个函数模块 // 打印不及格学生信息和所有学生信息程分别调用 #include<stdio.h> #include<stdlib.h> #include<string.h> #define N 10 // 运 阅读全文
摘要:
任务一 #include <stdio.h> const int N=3; int main() { int a[N] = {1, 2, 3}; int i; printf("通过数组名及下标直接访问数组元素:\n"); for(i=0; i<N; i++) printf("%d: %d\n", & 阅读全文
摘要:
任务一 return只能返回一个值,所以无法把多个根的结果返回给主调函数。 要想将方程的根返回给主调函数: ① 可以将x1,x2定义为全局变量,把结果赋值给全局变量,那么主调函数就可以使用方程的根。 ② 利用指针获取x1,x2的值。 任务二 // 利用局部static变量计算阶乘 #include 阅读全文
摘要:
任务一 #include<stdio.h> #include<math.h> int main(){ float a,b,c,x1,x2; float delta,real,imag; while(scanf("%f%f%f",&a,&b,&c)!=EOF){ if(a==0){ printf("n 阅读全文