ch9_5.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:1k
源码类别:
C#编程
开发平台:
Visual C++
- //*********************
- //** ch9_5.cpp **
- //*********************
- #include <iostream.h>
- bool Factor(int, int&, int&);
- void main()
- {
- int number,squared,cubed;
- bool error;
- cout <<"Enter a number(0~20): ";
- cin >>number;
- error=Factor(number,squared,cubed);
- if(error)
- cout <<"Error encountered!n";
- else{
- cout <<"Number: " <<number <<endl;
- cout <<"Squared: " <<squared <<endl;
- cout <<"Cubed: " <<cubed <<endl;
- }
- }
- bool Factor(int n, int& rSquared, int& rCubed)
- {
- if(n>20 || n<0)
- return true;
- rSquared = n*n;
- rCubed = n*n*n;
- return false;
- }