zoukankan      html  css  js  c++  java
  • 用动态链表high-poj 1528

    //2333333 题目超级水,但是!刚学了链表拿来high一high也不错啊。

    #include <iostream>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <algorithm>
    #include <queue>
    #include <math.h>
    #include <queue>
    #include <stack>
    using namespace std;
    #define INF 0x3f3f3f
    #define pi acos(-1.0)
    #define LL long long
    #define N 550
    typedef struct student* STU;
    #define LENTH sizeof(struct student)
    #define null 0
    struct student{
        int data;
        STU next;
    };
    
    STU creat_list(STU head)
    {
        STU p,q;
        head=p=(STU)malloc(LENTH);
        p->next=null;
        q=p;
        int x;
        while(cin>>x)
        {
            q->next=p;
            p->data=x;      
            q=p;
            q->next=null;
            if(x==0)
                break;
            p=(STU)malloc(LENTH);
        }
        return head;
    }
    void print(STU head)
    {
        STU p;
        p=head;
        int i,sum,n;
        while(p!=null)
        {
            n=p->data;
            if(n==0) break;
            else if(n==1) printf("%5d  DEFICIENT
    ",n);
            else 
            {
                sum=1;
                for(i=2;i<n;i++){
                    if(n%i==0)
                        sum+=i;
                }
                if(sum<n) printf("%5d  DEFICIENT
    ",n);
                else if(sum==n) printf("%5d  PERFECT
    ",n);
                else printf("%5d  ABUNDANT
    ",n);
            }
            p=p->next;
        }
    }
    
    int main()
    {
        STU head;
        head=creat_list(head);
        cout<<"PERFECTION OUTPUT"<<endl;
        print(head);
        cout<<"END OF OUTPUT"<<endl;
    }
  • 相关阅读:
    linux的ls命令输出结果的逐条解释
    dubbo用途介绍
    dubbo有什么作用
    来自19岁女孩和软件开发人员的建议
    C++的反思[转]
    mysql各种引擎对比、实战
    俗话:MySQL索引
    Mysql 30条军规
    MySQL事务原理&实战【官方精译】
    php-msf 源码解读【转】
  • 原文地址:https://www.cnblogs.com/keyboarder-zsq/p/5934534.html
Copyright © 2011-2022 走看看