⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2178637_ac_0ms_156k.cpp

📁 北大大牛代码 1240道题的原代码 超级权威
💻 CPP
字号:
#include <iostream>
#include <cmath>
#include <iomanip>
//why my codes got WA!!
using namespace std;
int main()
{
	long i,k;
	double x[4],y[4],tx,ty,l1,l2,b1,b2;
	cin>>k;
	cout<<"INTERSECTING LINES OUTPUT"<<endl;
	while (k!=0)
	{
		for (i=0;i<=3;i++) cin>>x[i]>>y[i];
		if (x[0]!=x[1])
		{
			l1=(y[1]-y[0])/(x[1]-x[0]);
			b1=y[1]-l1*x[1];
		}
		else 
		{
			l1=32768;
			b1=x[1];
		}
        if (x[2]!=x[3])
		{
			l2=(y[3]-y[2])/(x[3]-x[2]);
			b2=y[2]-l2*x[2];
		}
		else 
		{
			l2=32768;
			b2=x[2];
		}
		if (l1!=32768)
		{
			if (l2!=32768)
			{
				if (l1==l2)
				{
					if (b1==b2) cout<<"LINE"<<endl;
					else cout<<"NONE"<<endl;
				}
				else 
				{
					tx=(b2-b1)/(l1-l2);
					ty=l1*tx+b1;
					cout<<"POINT "<<setiosflags(ios::fixed)<<setprecision(2)<<tx<<' '<<ty<<endl;
				}
			}
			else
			{
				tx=b2;
				ty=l1*tx+b1;
				cout<<"POINT "<<setiosflags(ios::fixed)<<setprecision(2)<<tx<<' '<<ty<<endl;
			}
		}
		else
		{
			if (l2!=32768)
			{
				tx=b1;
				ty=l2*tx+b2;
				cout<<"POINT "<<setiosflags(ios::fixed)<<setprecision(2)<<tx<<' '<<ty<<endl;
			}
			else
			{
				if (b1==b2) cout<<"LINE"<<endl;
				else cout<<"NONE"<<endl;
			}
		}
        k--;
	}
	cout<<"END OF OUTPUT"<<endl;
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -