
C++程序题
一些C++程序题,本专栏所有源代码全部在DEV-C++5.11和VS2019这两个IDE(集成开发环境)下编译通过,没有任何错误和任何警告。
AKK188888881
这个作者很懒,什么都没留下…
展开
-
编写任何显示构造函数重载和函数重载的程序。
Write any program which shows constructor overloading and function overloading.编写任何显示构造函数重载和函数重载的程序。#include<iostream>using namespace std;int add(int,int);//声明函数add,用于对两个整数的相加 double add(double,double);//声明函数重载add,用于对两个浮点数的相加 class Box{ p原创 2020-06-21 23:12:09 · 230 阅读 · 0 评论 -
编写任何显示函数重写的程序。
Write any program which shows function overriding.编写任何显示函数重写的程序。#include<iostream>using namespace std; class Shape{ public: virtual float area() const { return 0.0; } virtual float volume() const { return 0.0; } virtu原创 2020-06-21 23:10:38 · 180 阅读 · 0 评论 -
编写一个程序,用户使用for循环输入5个数字,所有这些数字将存储在一个数组中。之后,程序将添加这五个数字并显示结果。程序必须支持运算符重载的概念。
Write a program in which users enter 5 numbers using for loop and all these numbers will store in an array. After that program will add these five numbers and show the result. Your program must support the concept of operator overloading.编写一个程序,用户使用for循环输原创 2020-06-21 23:09:08 · 4538 阅读 · 0 评论 -
什么是多级继承?使用多级继承编写一个程序,用户在其中输入数字,计算数字的立方体,如果数字的立方体大于150,则打印结果立方体的平方,否则显示消息“对不起”。
What is Multilevel inheritance? Write a program using multi-level inheritance in which the user enters the number, calculate the cube of the number, if the cube of the number is greater than 150 then print the square of the resultant cube, otherwise show t原创 2020-06-21 23:06:31 · 427 阅读 · 0 评论 -
什么是单一和多重继承。编写程序,根据以下规则查找使用多重继承的学生的成绩; 成绩大于80分为甲级 成绩大于70分小于80分为B级 如果分数大于50且小于70,则为C级 如果分数小于40,则为F
What are single and multiple inheritances. Write a program to find the grades of a student using multiple inheritances according to the following rules;Grade A if marks are > 80Grade B if marks are >70 and < 80Grade C if marks are > 50 and &原创 2020-06-21 23:04:10 · 321 阅读 · 0 评论 -
编写一个使用多级继承的程序,其中用户输入一个数字,程序将显示从1到10的给定数字的表。
Write a program using multi-level inheritance in which user enter a number, the program will show the table of the given number from 1 to 10.编写一个使用多级继承的程序,其中用户输入一个数字,程序将显示从1到10的给定数字的表。#include <iostream>using namespace std;class Table { pub原创 2020-06-21 22:56:07 · 321 阅读 · 0 评论 -
什么是多态性?使用多态性编写一个程序,如果数字是正的,数字也是偶数,则用户输入数字,然后打印数字的立方,如果数字是奇数和负数,则打印数字的平方。
What is polymorphism? Write a program using polymorphism in which user enters the number if the number is positive and the number is also even, then print the cube of the number and if the number is odd and negative then print the square of the number.什么是原创 2020-06-21 22:53:54 · 235 阅读 · 0 评论 -
输入三组数据,每组数据包含学号、名、姓、以及四次成绩,并输出每组数据的学号、名、姓、以及四次成绩的平均分。
Implement a Student class. Each object of this class will represent a student in a particular course. Data members should include the student’s ID number, first name, last name, and four exam scores. Methods should include a displayStudentInfo function an原创 2020-05-15 21:56:29 · 671 阅读 · 0 评论 -
剪刀石头布游戏。
Write a program that pits the human user against the computer in a game of “Rock, Paper, Scissors” as in the output below.Computer and user each choose one: R for Rock, P for Paper, S for Scissor.Each round, your program declares one the winner (ask user原创 2020-05-15 21:52:25 · 788 阅读 · 0 评论 -
输入N组学号Student ID,学分Credits,输入END结束,并计算出这些学分的平均值。
Write a program that accepts input data about a certain (unknown) number of CIS students. A set of input data contains the following information for each student:Student IDNumber of credits carried during the current semesterThe CIS department wishes原创 2020-05-15 21:47:56 · 486 阅读 · 0 评论