zoukankan      html  css  js  c++  java
  • HDU 1716 排列2

    题不难,格式真坑,PE了两天才找到错误,最后一组0 0 0 0数据是不能和上一组有空行的,之前一直PE的原因是下一组数据先空行再输入导致最后一组0 0 0 0怎么都有空行

    PE的:

    #include<iostream>
    #include<algorithm>
    
    using namespace std;
    
    int main(){
    
        int a[4];
    
        int flag=0;
    
    
    
    
            while(cin>>a[0]>>a[1]>>a[2]>>a[3]&&a[0]+a[1]+a[2]+a[3]!=0){
                int  flag2 = 0;
    			do{
                        if(a[0]==0)
                            continue;
                static int temp = a[0];
    
    			if(temp==a[0]&&flag2){
     			cout<<" ";}
    
    
    			else if(flag2)
    				cout<<endl;
                    cout<<a[0]<<a[1]<<a[2]<<a[3];
                flag2 = 1;
                temp=a[0];
              }while(next_permutation(a,a+4));
    		  if(a[0]+a[1]+a[2]+a[3]!=0&&flag){
              cout<<endl;
              flag=1;}
         cout<<endl;
         if(a[0]+a[1]+a[2]+a[3]!=0)
         cout<<endl;
        }
    
    
    	return 0;
    }
    

    AC的
    #include <iostream>
    #include <algorithm>
    using namespace std;
    int main(){
    int a[4];
    
    
        while(cin>>a[0]>>a[1]>>a[2]>>a[3]&&a[0]+a[1]+a[2]+a[3]!=0){
            static int flag = 0;
            if(flag){
                cout<<endl;}
                flag = 1;
                sort(a,a+4);
            int  flag2 = 0;
            do{
                    if(a[0]==0)
                        continue;
            static int temp = a[0];
    
            if(temp==a[0]&&flag2){
            cout<<" ";}
    
            else if(flag2)
                cout<<endl;
                cout<<a[0]<<a[1]<<a[2]<<a[3];
            flag2 = 1;
            temp=a[0];
          }while(next_permutation(a,a+4));
    
     if(a[0]+a[1]+a[2]+a[3]!=0)
     cout<<endl;
    }
    
    
    return 0;
    }


  • 相关阅读:
    SR-IOV(Single Root I/O Virtualization)
    DHCP&DHCPv6
    Linux 上的基础网络设备详解
    当Linux用尽内存-oom
    真爱了--网络工程师技能图谱
    程序员必备技能:如何画好架构图?
    Linux内存使用情况以及内存泄露情况
    Neutron 消息回调系统
    linux bridge
    OpenStack-Neutron-code
  • 原文地址:https://www.cnblogs.com/mingrigongchang/p/6246328.html
Copyright © 2011-2022 走看看