zoukankan      html  css  js  c++  java
  • online_judge_1178

    #include <stdio.h>
    #include <stdlib.h>
    #define M 1000
    int size;
    typedef struct Fushu
    {
        int a;
        int b;
    }Fushu;
    void fupop(Fushu *c)
    {
        int i,t=0;
        int max=c[0].a*c[0].a+c[0].b*c[0].b;
        for(i=1;i<size;i++)
        {
            if((c[i].a*c[i].a+c[i].b*c[i].b)>max)
            {
                max=c[i].a*c[i].a+c[i].b*c[i].b;
                t=i;
            }
            else if((c[i].a*c[i].a+c[i].b*c[i].b)==max&&c[i].a>c[t].a)
                t=i;
        }
        printf("%d+i%d
    ",c[t].a,c[t].b);
        printf("SIZE = %d
    ",--size);
        for(i=t;i<size;i++) c[i]=c[i+1];
    }
    void Insert(Fushu *c,char *s)
    {
        int x,y,i;
        x=s[7]-'0';i=8;
        while(s[i]!='+') x=10*x+s[i++]-'0';
        y=s[i+2]-'0';
        while(s[i+3]!='') y=y*10+s[i++ +3]-'0';
        c[size].a=x; c[size].b=y;
        size++;
        printf("SIZE = %d
    ",size);
    }
    int main()
    {
        int n,i;
        char str[20];
        Fushu d[M];
        while(scanf("%d",&n)!=EOF)
        {
            getchar();
            if(n<1||n>M) continue;
            i=0;#include <stdio.h>
    #include <stdlib.h>
    #define M 1000
    int size;
    typedef struct Fushu
    {
        int a;
        int b;
    }Fushu;
    void fupop(Fushu *c)
    {
        int i,t=0;
        int max=c[0].a*c[0].a+c[0].b*c[0].b;
        for(i=1;i<size;i++)
        {
            if((c[i].a*c[i].a+c[i].b*c[i].b)>max)
            {
                max=c[i].a*c[i].a+c[i].b*c[i].b;
                t=i;
            }
            else if((c[i].a*c[i].a+c[i].b*c[i].b)==max&&c[i].a>c[t].a)
                t=i;
        }
        printf("%d+i%d
    ",c[t].a,c[t].b);
        printf("SIZE = %d
    ",--size);
        for(i=t;i<size;i++) c[i]=c[i+1];
    }
    void Insert(Fushu *c,char *s)
    {
        int x,y,i;
        x=s[7]-'0';i=8;
        while(s[i]!='+') x=10*x+s[i++]-'0';
        y=s[i+2]-'0';
        while(s[i+3]!='') y=y*10+s[i++ +3]-'0';
        c[size].a=x; c[size].b=y;
        size++;
        printf("SIZE = %d
    ",size);
    }
    int main()
    {
        int n,i;
        char str[20];
        Fushu d[M];
        while(scanf("%d",&n)!=EOF)
        {
            getchar();
            if(n<1||n>M) continue;
            i=0;
            size=0;
            while(i<n)
            {
                gets(str);
                if(str[0]=='P')
                {
                    if(size==0) printf("empty
    ");
                    else fupop(d);
                }
                else if(str[0]=='I')
                    Insert(d,str);
                i++;
            }
        }
        return 0;
    }
    
            size=0;
            while(i<n)
            {
                gets(str);
                if(str[0]=='P')
                {
                    if(size==0) printf("empty
    ");
                    else fupop(d);
                }
                else if(str[0]=='I')
                    Insert(d,str);
                i++;
            }
        }
        return 0;
    }
    
    这次代码很杂,但是逻辑思路较以前更加清晰了!继续加油。。
  • 相关阅读:
    [板子]用线段树解决ST表问题
    [POJ2528]Mayor's posters(离散化+线段树)
    [板子]Kruskal
    [板子]segTree
    js实现工具函数中groupBy数据分组
    关于爬虫
    jsencrypt vue相关的rsa加密
    less 循环模拟sass的for循环效果
    vue 自动生成菜单
    vue中form 表单常用校验封装(async-validator)
  • 原文地址:https://www.cnblogs.com/abc-24990/p/4257473.html
Copyright © 2011-2022 走看看