#t1145. 矩形的面积与周长
矩形的面积与周长
Area and Perimeter of a Rectangle
Problem Description
The first lesson on structs: define a struct, access its members.
A struct packs several related values into a single object. Define a struct that represents a rectangle:
struct Rectangle {
int a; // length
int b; // width
};
Read the length and width of rectangles into struct variables, then print each rectangle's area () and perimeter (). Access the members with .a and .b.
Input Format
The first line contains a positive integer ; the next lines each contain two integers , the length and width of one rectangle.
Output Format
lines; line holds the area and the perimeter of the -th rectangle, separated by a space.
Sample Input
2
2 3
5 1
Sample Output
6 10
5 12
Constraints
For 100% of the test data, and .
Hint: this problem tests defining a struct and accessing its members — really define the struct, do not dodge it.