C++编程题,要所有代码加注释,急求! C++算法题 聚会 要求代码和注释

作者&投稿:淳邦 (若有异议请与网页底部的电邮联系)
#include<iostream>
using namespace std;
class Money
{
public:
Money(int pYuan=0, int pJiao=0, int pFen=0);
Money& operator + (Money& money);
Money& operator-(Money& money); //也可以用友元函数实现
void operator=(Money& money); //赋值运算符只能作为成员函数,而不能做友元函数
friend ostream& operator<<(ostream& output, Money& money);
private:
int yuan;
int jiao;
int fen;
};
Money::Money(int pYuan, int pJiao, int pFen)
{
yuan = pYuan;
jiao = pJiao;
fen = pFen;
}
Money& Money::operator +(Money& money)
{
int yuan;
int jiao;
int fen;
yuan = this->yuan + money.yuan;
jiao = this->jiao + money.jiao;
fen = this->fen + money.fen;
if(fen >= 10)
{
jiao += 1;
fen -= 10;
}
if(jiao >= 10)
{
yuan += 1;
jiao -= 10;
}
return Money(yuan, jiao, fen);
}

Money& Money::operator-(Money& money)
{
int yuan;
int jiao;
int fen;
fen = this->fen - money.fen;
if(fen < 0)
{
this->jiao -= 1;
fen += 10;
}
jiao = this->jiao - money.jiao;
if(jiao < 0)
{
this->yuan -= 1;
jiao += 10;
}
yuan = this->yuan - money.yuan;

return Money(yuan, jiao, fen);
}

void Money::operator=(Money& money)
{
yuan = money.yuan;
jiao = money.jiao;
fen = money.fen;
}
ostream& operator<<(ostream& output,Money& money)
{
output<<money.yuan<<"元"<<money.jiao<<"角"<<money.fen<<"分"<<endl;
return output;
}

void main()
{
Money money1(3,6,4);
Money money2(1,7,9);
Money money3;
Money money4;
Money money5;
money3=money1+money2;
money4=money1-money2;
money5=money4;
cout<<money3;
cout<<money4;
cout<<money5;
}
在VS2005中编译没问题,如果在VC6.0中有问题将头两行换为
#include<iostream.h>即可

C++编程问题,给下面的程序每行加上注释~

估计这个程序都不是你写的。

类似与你的要求,不过输入格式跟你不太一样。
主要是我看不明白122145是什么意思

很急啊~asp.net(c#)编程问题,高手请帮忙!谢谢啊~请帮忙每一句详细注释...
答://判断链接状态如果关闭的情况 if (Lb_Conn.State==ConnectionState.Closed){//就打开 Lb_Conn.Open();} } public void DBclose(){ //判断链接状态如果打开的情况 if (Lb_Conn.State==ConnectionState.Open){ //就关闭 Lb_Conn.Close();} } //使用构造出来的SQL语句和链接对象用SqlData...

C语言编程题,求5!+16!+27!,定义函数求n! 用程序流程图表示出算法,代码...
答:如果需要精确计算16和27的阶乘需要编写大整数计算,至少要实现大整数加法,大整数乘以短整数,大整数除以短整数,大整数转换为字符串用于显示结果。当然如果不需要精确计算可以使用浮点数来计算。include <stdio.h>#include <string.h>#include <malloc.h>#include <ctype.h>typedef int BOOL;typedef ...

求java题源代码,最好有注释,
答:2017-06-20 求JAVA源代码,要有注释,所有财富都在下面了 1 2012-01-02 求这个JAVA编程题的答案,最好每一部都有解释 1 2014-09-17 java编程问题,学渣求详细代码,最好有注释 2014-03-03 求用java编写的 试卷生成与题库管理系统的源代码? 加上详... 1 2015-07-08 求一java程序,一个界面计算器源...

...把以下的题目代码发一下,能做几个都好,只要注释全就行~
答:还是耐着性子给你做完了望采纳。。。第七题/** * 动物抽象类 */public abstract class Animal {//颜色private String color;//类别private String type;//吃饭public abstract void eat();//叫public abstract void cry();//get set方法省略。。。}/** * 游泳的接口 */public interface Swim...

c++题目,最好带注释
答:include <iostream>using namespace std;class CTime{protected:int hour;int minute;int second;public://无参构造函数CTime(){this->hour = 0;this->minute = 0;this->second = 0;//cout<<"CTime()"<<endl;//}//带参构造函数CTime(int hour, int minute, int second){this->hour = ...

C语言,关于栈的问题 给下面的程序加上注释,并给出运行结果:
答:DATATYPE2 pop(SEQSTACK *s)//弹出堆栈s的顶层元素 { DATATYPE2 x;if(empty(s)){printf("underflow\n");//如果堆栈为空,则显示underflow x=NULL;} else {x=(s->data)[s->top];s->top--;} return x;} main(){ SEQSTACK s,*p;char x,y;p=&s;initstack(p);//初始化堆栈 x=...

c++基础编程题两道,谢谢,最好有注释,欢迎加qq讨论
答:include"iostream"using namespace std;class Point { private:double x,y;public:Point(double x1,double y1);~Point(){} void PrintCoordinate();};Point::Point(double x1,double y1){ x=x1;y=y1;} void Point::PrintCoordinate(){ cout<<"Coordinate: x= "<<x<<" y= "<<y<<endl;...

程序注释题:读程序,写出程序的功能,并为每一句程序进行注释#include<s...
答:则加到*odd中else *even=*even+*a; //否则,是偶数,则加到*even中a++; //指针后移一位,准备处理下一个数}}void main(){int a[6],i,odd,even;printf("please input the number to the array:");for(i=0;i<n;i++) //此行开始的2行,输入6个整数并存入数组ascanf("...

C++:大佬,下面题目咋写(要有点注释)?
答:代码文本://#include "stdafx.h"//vc++ 6.0? Maybe should add this line.include <iostream> using namespace std;int main(int argc,char *argv[]){ int n;double s;cout << "Please enter your score n(int 0<=n<2001)...\n";if((cin >> n) && n>=0 && n<2001){ if(...

一条oj的题目。。。求代码跟注释,C语言。。。
答:能用的话,希望可以加分。include <iostream>#include <algorithm>#include <vector>#include <string>using namespace std;//***///arr:输入的数据(二维数组)///str:待匹配字符串///n/m:二维数组的行数/列数///vol/col:待比较的数据位置(行/列)///path:检索方向///***//int compare(v...