九层for循环,全wa
查看原帖
九层for循环,全wa
1269314
LiChenyi05楼主2024/3/29 23:16
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
	int A,B,C;
	cin>>A>>B>>C;
	for(int a=1;a<=9;a++)
	{
		for(int b=1;b<=9&&b!=a;b++)
		{
			for(int c=1;c<=9&&c!=a&&c!=b;c++)
			{
				for(int d=1;d<=9&&d!=a&&d!=b&&d!=c;d++)
				{
					for(int e=1;e<=9&&e!=a&&e!=b&&e!=c&&e!=d;e++)
					{
						for(int f=1;f<=9&&f!=a&&f!=b&&f!=c&&f!=d&&f!=e;f++)
						{
							for(int g=1;g<=9&&g!=a&&g!=b&&g!=c&&g!=d&&g!=e&&g!=f;g++)
							{
								for(int h=1;h<=9&&h!=a&&h!=b&&h!=c&&h!=d&&h!=e&&h!=f&&h!=g;h++)
								{
									for(int i=1;i<=9&&i!=a&&i!=b&&i!=c&&i!=d&&i!=e&&i!=f&&i!=g&&i!=h;i++)
									{
										int ans1=(a*100+b*10+c)*B*C;
										int ans2=(d*100+e*10+f)*A*C;
										int ans3=(g*100+h*10+i)*A*B;
										if(ans1==ans2&&ans1==ans3)
										{
											cout<<a<<b<<c<<" "<<d<<e<<f<<" "<<g<<h<<i<<endl;
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	return 0;
}

在编译器上连结果都不输出,这是为啥啊

2024/3/29 23:16
加载中...