为什么我错了,哪位大佬帮忙看看?

lyh098 仙辞 2024-02-05 9:54:14 20

#include <bits/stdc++.h> using namespace std; int main() { long long int n, i, s; cin >> n; i = 1; s = 0; while (i <= n) { s = s * i; i++; } cout << s; }

{{ vote && vote.total.up }}

共 3 条回复

xueruogu

#include using namespace std;

int main(){ int n,s=1; cin>>n; for(int i=2;i<=n;i++){ s *= i; } cout<<s; return 0; }

yanghy

而且n=0呢?

yanghy

0乘任何数都为0 因该是s赋值为1;