Generation

generate functionFri, 07 Jul 2023

実数xと整数nをキーボードから入力し、1つのdo文を用いてべき乗(xのn乗)とnの階乗を計算し、x、n、べき乗を出力せよ。

int x; int n; int pow = 1; int fact = 1; cin >> x >> n; for (int i = 1; i <= n; i++) { pow *= x; fact *= i; } cout << x << ' ' << n << ' ' << pow << endl;

Want to kickstart your project?Use the new AI Studio to create your code