c++快速入门 第六讲课后题
不会做啊,求大神帮忙(函数重载,calc()函数) 问个问题都不会问 l万lin 发表于 2013-3-30 12:39 static/image/common/back.gif问个问题都不会问
纯属菜鸟,尽请谅解 我写的你看看,纯属新手,见谅
话说有人知道C++的课后题板块在哪儿了么??
#include<iostream>
using namespace std;
int calc(int a);
int calc(int a,int b);
int calc(int a,int b,int c);
int main()
{
int i;
cout << "please input 1 number:" ;
cin >>i;
cout << calc(i);
int j;
cout << "please input 2 numbers:" ;
cin >> i >> j;
cout << calc(i,j);
int k;
cout << "please input 3 numbers:" ;
cin >> i >> j >> k;
calc(i,j,k);
cout << calc(i,j,k);
return (0);
}
calc(int a)
{
int result;
result = a*a;
return (result);
}
calc(int a,int b)
{
int result;
result = a*b;
return (result);
}
calc(int a,int b,int c)
{
int result;
result = a+b+c;
return (result);
} {:5_104:}aaaaaa pcfate 发表于 2013-5-9 23:07 static/image/common/back.gif
我写的你看看,纯属新手,见谅
话说有人知道C++的课后题板块在哪儿了么??
补个cin.ignore(100 , '\n');
页:
[1]