Advertisement
Guest User

C++ week2

a guest
Mar 23rd, 2024
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main() {
  4.     // 长100->a 宽30->b
  5.     int a = 100, b = 30;
  6.     // 周长,面积
  7.     // (a+b) *2
  8.     // ab
  9.     int C = (a+b)*2;
  10.     int S = a*b;
  11.     cout << C << endl;
  12.     cout << S << endl;
  13.     return 0;
  14. }
  15.  
  16. #include<iostream>
  17. using namespace std;
  18. int main() {
  19.     // 上底 3 下底 6  高4.5
  20.     int a = 3, b = 6;
  21.     double h = 4.5;
  22.    
  23.     cout << (a+b)*h/2 << endl;
  24.     return 0;
  25. }
  26.  
  27. #include<iostream>
  28. using namespace std;
  29. int main() {
  30.     // 头 -> head 腿->leg
  31.     int head = 50, leg = 160;
  32.     // 鸡
  33.     int chicken = (4*head-leg) / 2;
  34.     // 兔
  35.     int rabbit = head - chicken;
  36.     cout << chicken << " " << rabbit << endl;
  37.     return 0;
  38. }
  39.  
  40. #include<iostream>
  41. using namespace std;
  42. int main() {
  43.     // 总数->n 车轮->wheel
  44.     int n = 10, wheel = 26;
  45.     // 自行车 -> b 三轮车 -> t
  46.     int b, t;
  47.     // 自行车
  48.     b = 3*n-wheel;
  49.     // 三轮车
  50.     t = n - b;
  51.     cout << b << " " << t << endl;
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement