游客 Signup | Login
中文 | En

3705 - C++作业3-1:编写内联函数求矩形的面积和周长

编写函数求矩形的面积和周长,由于算式非常简单,请使用内联函数方式编写,提高程序运行效率

Input

矩形的长和宽,均为整数

Output

矩形的面积和周长

Examples

Input

3 5

Output

15 16

Hint

定义内联函数需使用关键词inline

Solution C++

#include<iostream>
using namespace std;
inline int calArea(int length,int width){
  return length*width;
}
inline int calPerimeter(int length,int width){
  return 2*(length+width);
}
int main(){
int length,width;
  cin>>length>>width;
  int area=calArea(length,width);
  int primeter=calPerimeter(length,width);
  cout<<area<<' '<<primeter<<endl;
  return 0;
}

Hint

定义内联函数需使用关键词inline

Time Limit 1 second
Memory Limit 30 MB
Discuss Stats
上一题 下一题