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;
    }
    
    这次代码很杂,但是逻辑思路较以前更加清晰了!继续加油。。
  • 相关阅读:
    jquery获得url的get参数
    WampServer更改或重置数据库密码
    phpexcel乱码问题
    5kcrm增加权限管理中的模块(签到统计)
    windows关于定时执行的php脚本
    php 中引入邮箱服务 , 利用第三方的smtp邮件服务
    thinkphp 多个字段的不同关系的查询条件实现 .
    redis与memcached有什么区别
    MYSQL语句大全
    使用HttpClient工具类发起Restful API调用
  • 原文地址:https://www.cnblogs.com/abc-24990/p/4257473.html
Copyright © 2011-2022 走看看