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;
    }
    
    这次代码很杂,但是逻辑思路较以前更加清晰了!继续加油。。
  • 相关阅读:
    ubuntu 15.10 64bit 下 steam无法启动
    ubuntu下使用OBS开斗鱼直播
    sql server 2008 management studio安装教程
    navicat for mysql 破解版
    nginx 重写去掉index.php
    phpstorm 注册码破解
    tp where使用数组条件,如何设置or,and
    PHPstorm 配置主题
    IE下无法保存Cookie和Session问题
    GitLab的安装及使用
  • 原文地址:https://www.cnblogs.com/abc-24990/p/4257473.html
Copyright © 2011-2022 走看看