蒟蒻求助,为什么没法找到呢?输出全是NO
查看原帖
蒟蒻求助,为什么没法找到呢?输出全是NO
547513
daonan楼主2022/2/4 23:59
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,y,z;
	int ass=0;
	cin>>x>>y>>z;
	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 t=a*100+b*10+c;
    									int j=d*100+e*10+f;
    									int k=g*100+h*10+i;
    									if((double)(t/j)==(double)(x/y)&&(double)(j/k)==(double)(y/z))
    									{
    										cout<<a<<b<<c<<' '<<d<<e<<f<<' '<<g<<h<<i<<endl;
    										ass++;
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	if(ass==0)
	cout<<"No!!!";
	return 0;
}
2022/2/4 23:59
加载中...