为什么我的这个代码会死循环?求大佬帮助。
查看原帖
为什么我的这个代码会死循环?求大佬帮助。
1163819
LiXinLong_LXL楼主2024/5/6 22:28
#include<bits/stdc++.h>
using namespace std;

int main(){
	int n;
	cin>>n;
	bool f=0;
	for(int a=1;a<=3;a++)
	for(int b=1;b<=3;b++)
	for(int c=1;c<=3;c++)
	for(int d=1;d<=3;d++)
	for(int e=1;e<=3;e++)
	for(int f=1;f<=3;f++)
	for(int g=1;g<=3;g++)
	for(int h=1;h<=3;h++)
	for(int i=1;i<=3;i++)
	for(int j=1;j<=3;j++)
	if(a+b+c+d+e+f+g+h+i+j==n){
		cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "<<f<<" "<<g<<" "<<h<<" "<<i<<" "<<j<<endl;
		f=1;
	}
	if(f==0) cout<<f;
    return 0;
}

2024/5/6 22:28
加载中...