求大神解答,这个程序出了什么有关问题啊
求大神解答,这个程序出了什么问题啊。。。
#include <iostream.h>
#include <stdlib.h>
#include <math.h>
void main_option()
{
cout << "常用的数学函数: \n" ;
cout << "1.绝对值函数: \n" ;
cout << "2.幂函数: \n" ;
cout << "3.三角函数: \n" ;
cout << "4.对数函数: \n" ;
cout << "5.其他函数: \n" ;
cout << "0.退出 \n" ;
cout << "Enter your choice:" ;
}
void option_1()
{
cout << "绝对值函数: \n" ;
cout << "1.abs() \n" ;
cout << "2.labs() \n" ;
cout << "3.fabs() \n" ;
cout << "0.exit \n" ;
cout << "Enter your choice:" ;
}
void option_2()
{
cout << "幂函数: \n" ;
cout << "1.pow() \n" ;
cout << "2.sqrt() \n" ;
cout << "0.exit \n" ;
cout << "Enter your choice:" ;
}
void option_3()
{
cout << "三角函数: \n" ;
cout << "1.cos() \n" ;
cout << "2.sin() \n" ;
cout << "3.tan() \n" ;
cout << "0.exit \n" ;
cout << "Enter your choice:" ;
}
void option_4()
{
cout << "对数函数: \n" ;
cout << "1.exp() \n" ;
cout << "2.log() \n" ;
cout << "3.log10() \n";
cout << "0.exit \n" ;
cout << "Enter your choice:" ;
}
void option_5()
{
cout << "其他函数: \n" ;
cout << "1.ceil() \n" ;
cout << "2.floor() \n" ;
cout << "3.fmod() \n" ;
cout << "0.exit \n" ;
cout << "Enter your choice:" ;
}
void abs()
{
int x ;
cout << "请输入一个数字: \n" ;
cin >> x ;
cout << abs(x) << "\n" ;
}
void labs()
{
long x ;
cout << "请输入一个数字: \n" ;
cin >> x ;
cout << labs(x) << "\n" ;
}
void fabs()
{
double x ;
cout << "请输入一个数字: \n" ;
cin >> x ;
cout << fabs(x) << "\n" ;
}
void pow()
{
int x ;int y ;
cout << "输入所求式的底数: \n" ;
cin >> x ;
cout << "输入所求式的指数: \n" ;
cin >> y ;
cout << pow(x,y) << "\n" ;
}
void sqrt()
{
int x ;
cout << "输入一个数字: \n" ;
cin >> x ;
cout << sqrt(x) << "\n" ;
}
void cos()
{
float x ;
cout << "输入一个弧度: \n" ;
cin >> x ;
cout << cos(x) << "\n" ;
}
void sin()
{
float x ;
cout << "输入一个弧度: \n" ;
cin >> x ;
cout << sin(x) << "\n" ;
}
void tan()
{
float x ;
cout << "输入一个弧度: \n" ;
cin >> x ;
cout << tan(x) << "\n" ;
}
void exp()
{
float x ;
cout << "输入一个数字: \n" ;
cin >> x ;
cout << exp(x) << "\n" ;
}
void log()
{
float x ;
cout << "输入一个数字: \n" ;
cin >> x ;
cout << log(x) << "\n" ;
}
void log10()
{
float x ;
cout << "输入一个数字: \n" ;
cin >> x ;
cout << log10(x) << "\n" ;
}
void ceil()
{
double x ;
cout << "输入一个数字: \n" ;
cin >> x ;
cout << ceil(x) << "\n" ;
}
void my_ceil()
{
double x;
cout << "输入一个数字: \n" ;
cin >> x ;
cout << ceil(x) << "\n" ;
}
void floor()
{
double x ;
cout << "输入一个数字: \n" ;
cin >> x ;
cout << floor(x) << "\n" ;
}
void fmod()
{
float x, y;
cout << "输入一个数字: \n" ;
cin >> x ;
cout << "输入一个数字: \n" ;
cin >> y ;
cout << fmod(x,y) << "\n" ;
}
void __1()
{
option_1() ;
int choice ;
while (choice != 0) {
switch (choice) {
case 0:
break ;
case 1:
cout << "Your choice is 1.abs() \n" ;
break ;
case 2:
cout << "Your choice is 2.labs() \n" ;
break ;
case 3:
cout << "Your choice is 3.fabs() \n" ;
break ;
}
option_1() ;
cin >> choice ;
}
cout << "Thank you for your choice. \n" ;
}
void __2()
{
option_2() ;
int choice ;
while (choice != 0) {
switch (choice) {
case 0:
break ;
case 1:
cout << "Your choice is 1.pow() \n" ;
break ;
case 2:
cout << "Your choice is 2.sqrt() \n" ;
break ;
}
option_2() ;
cin >> choice ;
}
cout << "Thank you for your choice. \n" ;
}
void __3()
{
option_3() ;
int choice ;
while (choice != 0) {
switch (choice) {
case 0:
break ;
case 1:
cout << "Your choice is 1.cos() \n" ;
break ;
case 2:
cout << "Your choice is 2.sin() \n" ;
break ;
case 3:
cout << "Your choice is 3.tan() \n" ;
break ;
}
option_3() ;
cin >> choice ;
}
cout << "Thank you for your choice. \n" ;
}
void __4()
{
option_4() ;
int choice ;
while (choice != 0) {
switch (choice) {
case 0:
break ;
case 1:
cout << "Your choice is 1.exp() \n" ;
break ;
case 2:
cout << "Your choice is 2.log() \n" ;
break ;
case 3:
cout << "Your choice is 3.log10() \n" ;
break ;
}
option_4() ;
cin >> choice ;
}
cout << "Thank you for your choice. \n" ;
}
void __5()
{
option_5() ;
int choice ;
while (choice != 0) {
switch (choice) {
case 0:
break ;
case 1:
cout << "Your choice is 1.ceil() \n" ;
break ;
case 2:
cout << "Your choice is 2.floor() \n" ;
break ;
case 3:
cout << "Your choice is 3.fmod() \n" ;
break ;
}
option_5() ;
cin >> choice ;
}
cout << "Thank you for your choice. \n" ;
}
void main ()
{
main_option();
int choice ;
cin >> choice ;
while (choice != 0) {
switch (choice) {
case 1:
__1() ;
break ;
case 2:
__2() ;
break ;
case 3:
__3() ;
break ;
case 4:
__4() ;
break ;
case 5:
__5() ;
break ;
}
main_option() ;
cin >> choice ;
}
}
------解决思路----------------------
这个简单,你在所有命名为“_一个数字”的函数里,把输出语句类似cout << "Your choice is 1.ceil() \n";改成ceil();
以下是参考:
#include <iostream.h>
#include <stdlib.h>
#include <math.h>
void main_option()
{
cout << "常用的数学函数: \n" ;
cout << "1.绝对值函数: \n" ;
cout << "2.幂函数: \n" ;
cout << "3.三角函数: \n" ;
cout << "4.对数函数: \n" ;
cout << "5.其他函数: \n" ;
cout << "0.退出 \n" ;
cout << "Enter your choice:" ;
}
void option_1()
{
cout << "绝对值函数: \n" ;
cout << "1.abs() \n" ;
cout << "2.labs() \n" ;
cout << "3.fabs() \n" ;
cout << "0.exit \n" ;
cout << "Enter your choice:" ;
}
void option_2()
{
cout << "幂函数: \n" ;
cout << "1.pow() \n" ;
cout << "2.sqrt() \n" ;
cout << "0.exit \n" ;
cout << "Enter your choice:" ;
}
void option_3()
{
cout << "三角函数: \n" ;
cout << "1.cos() \n" ;
cout << "2.sin() \n" ;
cout << "3.tan() \n" ;
cout << "0.exit \n" ;
cout << "Enter your choice:" ;
}
void option_4()
{
cout << "对数函数: \n" ;
cout << "1.exp() \n" ;
cout << "2.log() \n" ;
cout << "3.log10() \n";
cout << "0.exit \n" ;
cout << "Enter your choice:" ;
}
void option_5()
{
cout << "其他函数: \n" ;
cout << "1.ceil() \n" ;
cout << "2.floor() \n" ;
cout << "3.fmod() \n" ;
cout << "0.exit \n" ;
cout << "Enter your choice:" ;
}
void abs()
{
int x ;
cout << "请输入一个数字: \n" ;
cin >> x ;
cout << abs(x) << "\n" ;
}
void labs()
{
long x ;
cout << "请输入一个数字: \n" ;
cin >> x ;
cout << labs(x) << "\n" ;
}
void fabs()
{
double x ;
cout << "请输入一个数字: \n" ;
cin >> x ;
cout << fabs(x) << "\n" ;
}
void pow()
{
int x ;int y ;
cout << "输入所求式的底数: \n" ;
cin >> x ;
cout << "输入所求式的指数: \n" ;
cin >> y ;
cout << pow(x,y) << "\n" ;
}
void sqrt()
{
int x ;
cout << "输入一个数字: \n" ;
cin >> x ;
cout << sqrt(x) << "\n" ;
}
void cos()
{
float x ;
cout << "输入一个弧度: \n" ;
cin >> x ;
cout << cos(x) << "\n" ;
}
void sin()
{
float x ;
cout << "输入一个弧度: \n" ;
cin >> x ;
cout << sin(x) << "\n" ;
}
void tan()
{
float x ;
cout << "输入一个弧度: \n" ;
cin >> x ;
cout << tan(x) << "\n" ;
}
void exp()
{
float x ;
cout << "输入一个数字: \n" ;
cin >> x ;
cout << exp(x) << "\n" ;
}
void log()
{
float x ;
cout << "输入一个数字: \n" ;
cin >> x ;
cout << log(x) << "\n" ;
}
void log10()
{
float x ;
cout << "输入一个数字: \n" ;
cin >> x ;
cout << log10(x) << "\n" ;
}
void ceil()
{
double x ;
cout << "输入一个数字: \n" ;
cin >> x ;
cout << ceil(x) << "\n" ;
}
void my_ceil()
{
double x;
cout << "输入一个数字: \n" ;
cin >> x ;
cout << ceil(x) << "\n" ;
}
void floor()
{
double x ;
cout << "输入一个数字: \n" ;
cin >> x ;
cout << floor(x) << "\n" ;
}
void fmod()
{
float x, y;
cout << "输入一个数字: \n" ;
cin >> x ;
cout << "输入一个数字: \n" ;
cin >> y ;
cout << fmod(x,y) << "\n" ;
}
void __1()
{
option_1() ;
int choice ;
while (choice != 0) {
switch (choice) {
case 0:
break ;
case 1:
cout << "Your choice is 1.abs() \n" ;
break ;
case 2:
cout << "Your choice is 2.labs() \n" ;
break ;
case 3:
cout << "Your choice is 3.fabs() \n" ;
break ;
}
option_1() ;
cin >> choice ;
}
cout << "Thank you for your choice. \n" ;
}
void __2()
{
option_2() ;
int choice ;
while (choice != 0) {
switch (choice) {
case 0:
break ;
case 1:
cout << "Your choice is 1.pow() \n" ;
break ;
case 2:
cout << "Your choice is 2.sqrt() \n" ;
break ;
}
option_2() ;
cin >> choice ;
}
cout << "Thank you for your choice. \n" ;
}
void __3()
{
option_3() ;
int choice ;
while (choice != 0) {
switch (choice) {
case 0:
break ;
case 1:
cout << "Your choice is 1.cos() \n" ;
break ;
case 2:
cout << "Your choice is 2.sin() \n" ;
break ;
case 3:
cout << "Your choice is 3.tan() \n" ;
break ;
}
option_3() ;
cin >> choice ;
}
cout << "Thank you for your choice. \n" ;
}
void __4()
{
option_4() ;
int choice ;
while (choice != 0) {
switch (choice) {
case 0:
break ;
case 1:
cout << "Your choice is 1.exp() \n" ;
break ;
case 2:
cout << "Your choice is 2.log() \n" ;
break ;
case 3:
cout << "Your choice is 3.log10() \n" ;
break ;
}
option_4() ;
cin >> choice ;
}
cout << "Thank you for your choice. \n" ;
}
void __5()
{
option_5() ;
int choice ;
while (choice != 0) {
switch (choice) {
case 0:
break ;
case 1:
cout << "Your choice is 1.ceil() \n" ;
break ;
case 2:
cout << "Your choice is 2.floor() \n" ;
break ;
case 3:
cout << "Your choice is 3.fmod() \n" ;
break ;
}
option_5() ;
cin >> choice ;
}
cout << "Thank you for your choice. \n" ;
}
void main ()
{
main_option();
int choice ;
cin >> choice ;
while (choice != 0) {
switch (choice) {
case 1:
__1() ;
break ;
case 2:
__2() ;
break ;
case 3:
__3() ;
break ;
case 4:
__4() ;
break ;
case 5:
__5() ;
break ;
}
main_option() ;
cin >> choice ;
}
}
------解决思路----------------------
这个简单,你在所有命名为“_一个数字”的函数里,把输出语句类似cout << "Your choice is 1.ceil() \n";改成ceil();
以下是参考:
#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;
void main_option(){
cout << "常用的数学函数: \n";
cout << "1.绝对值函数: \n";
cout << "2.幂函数: \n";
cout << "3.三角函数: \n";
cout << "4.对数函数: \n";
cout << "5.其他函数: \n";
cout << "0.退出 \n";
cout << "Enter your choice:";
}
void option_1(){
cout << "绝对值函数: \n";
cout << "1.abs() \n";
cout << "2.labs() \n";
cout << "3.fabs() \n";
cout << "0.exit \n";
cout << "Enter your choice:";
}
void option_2(){
cout << "幂函数: \n";
cout << "1.pow() \n";
cout << "2.sqrt() \n";
cout << "0.exit \n";
cout << "Enter your choice:";
}
void option_3(){
cout << "三角函数: \n";
cout << "1.cos() \n";
cout << "2.sin() \n";
cout << "3.tan() \n";
cout << "0.exit \n";
cout << "Enter your choice:";
}
void option_4(){
cout << "对数函数: \n";
cout << "1.exp() \n";
cout << "2.log() \n";
cout << "3.log10() \n";
cout << "0.exit \n";
cout << "Enter your choice:";
}
void option_5(){
cout << "其他函数: \n";
cout << "1.ceil() \n";
cout << "2.floor() \n";
cout << "3.fmod() \n";
cout << "0.exit \n";
cout << "Enter your choice:";
}
void abs(){
int x;
cout << "请输入一个数字: \n";
cin >> x;
cout << abs(x) << "\n";
}
void labs(){
long x;
cout << "请输入一个数字: \n";
cin >> x;
cout << labs(x) << "\n";
}
void fabs(){
double x;
cout << "请输入一个数字: \n";
cin >> x;
cout << fabs(x) << "\n";
}
void pow(){
int x;
int y;
cout << "输入所求式的底数: \n";
cin >> x;
cout << "输入所求式的指数: \n";
cin >> y;
cout << pow(x, y) << "\n";
}
void sqrt(){
int x;
cout << "输入一个数字: \n";
cin >> x;
cout << sqrt(x) << "\n";
}
void cos(){
float x;
cout << "输入一个弧度: \n";
cin >> x;
cout << cos(x) << "\n";
}
void sin(){
float x;
cout << "输入一个弧度: \n";
cin >> x;
cout << sin(x) << "\n";
}
void tan(){
float x;
cout << "输入一个弧度: \n";
cin >> x;
cout << tan(x) << "\n";
}
void exp(){
float x;
cout << "输入一个数字: \n";
cin >> x;
cout << exp(x) << "\n";
}
void log(){
float x;
cout << "输入一个数字: \n";
cin >> x;
cout << log(x) << "\n";
}
void log10(){
float x;
cout << "输入一个数字: \n";
cin >> x;
cout << log10(x) << "\n";
}
void ceil(){
double x;
cout << "输入一个数字: \n";
cin >> x;
cout << ceil(x) << "\n";
}
void my_ceil(){
double x;
cout << "输入一个数字: \n";
cin >> x;
cout << ceil(x) << "\n";
}
void floor(){
double x;
cout << "输入一个数字: \n";
cin >> x;
cout << floor(x) << "\n";
}
void fmod(){
float x, y;
cout << "输入一个数字: \n";
cin >> x;
cout << "输入一个数字: \n";
cin >> y;
cout << fmod(x, y) << "\n";
}
void __1(){
option_1();
int choice;
cin >> choice;
while (choice != 0){
switch (choice){
case 0:
break;
case 1:
abs();
break;
case 2:
labs();
break;
case 3:
fabs();
break;
}
option_1();
cin >> choice;
}
cout << "Thank you for your choice. \n";
}
void __2(){
option_2();
int choice;
cin >> choice;
while (choice != 0){
switch (choice){
case 0:
break;
case 1:
pow();
break;
case 2:
sqrt();
break;
}
option_2();
cin >> choice;
}
cout << "Thank you for your choice. \n";
}
void __3(){
option_3();
int choice;
cin >> choice;
while (choice != 0){
switch (choice){
case 0:
break;
case 1:
cos();
break;
case 2:
sin();
break;
case 3:
tan();
break;
}
option_3();
cin >> choice;
}
cout << "Thank you for your choice. \n";
}
void __4(){
option_4();
int choice;
cin >> choice;
while (choice != 0){
switch (choice){
case 0:
break;
case 1:
exp();
break;
case 2:
log();
break;
case 3:
log10();
break;
}
option_4();
cin >> choice;
}
cout << "Thank you for your choice. \n";
}
void __5(){
option_5();
int choice;
cin >> choice;
while (choice != 0){
switch (choice) {
case 0:
break;
case 1:
ceil();
break;
case 2:
floor();
break;
case 3:
fmod();
break;
}
option_5();
cin >> choice;
}
cout << "Thank you for your choice. \n";
}
int main(){
main_option();
int choice;
cin >> choice;
while (choice != 0){
switch (choice) {
case 1:
__1();
break;
case 2:
__2();
break;
case 3:
__3();
break;
case 4:
__4();
break;
case 5:
__5();
break;
}
main_option();
cin >> choice;
}
return 0;
}