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

📄 2678468_ac_343ms_272k.cc

📁 做的POJ的一些题目
💻 CC
字号:
#include<iostream>
using namespace std;
typedef struct 
{
	float x,y;
}pointt;
typedef struct
{
    float k;  
}node;
int cmp(const void * a, const void * b)

{
    return((*(float*)a-*(float*)b>0)?1:-1);
}
int main()
{
    int n,total=2,c=0;
    while(true)
    {
        scanf("%d",&n);
        if(n==0)
          break;
        pointt mg[n];
        for(int i=0;i<n;i++)
         scanf("%f %f",&mg[i].x,&mg[i].y); 
        for(int i=0;i<n;i++)
        {
           node num[n+1];
           int h=0;
           for(int j=i+1;j<n;j++)
             if(mg[i].x!=mg[j].x)
              num[h++].k=(mg[j].y-mg[i].y)/(mg[j].x-mg[i].x);
             else
               num[h++].k=100000;
           qsort(num,h,sizeof(num[0]),cmp);
 			int c=2;
			for(int j=1;j<h;j++)
            {
				if(num[j].k==num[j-1].k)	
                   c++;
				else
                {
					if(total<c)
    	              total=c;
					c=2;
				}
             }
			if(total<c)
               total=c;
        }
        printf("%d\n",total);   
        total=2;
    }
    system("pause");
    return 0;
}

⌨️ 快捷键说明

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