zoukankan      html  css  js  c++  java
  • 2013=8=1 今天我发现自己真的不够优秀

    #include <iostream>
    #include <algorithm>
    #include <string>
    int a[10];
    using namespace std;
    int f(int x)
    { for(int i=2;i<x ; i++)
       if( x%i==0 )    return 0;
        return 1; 
    }

    int main( )
    {  int i,j,n,ok;
      cin>>n;
      for(i=0; i<n;i++) a[i]=i+1;
    do
    {   ok=1 ;
      for(j=1; j<n;j++)
        if(! f(a[j-1]+a[j]) )  { ok=0 ; break ; }
      if(!f(a[0]+a[n-1]))  ok=0 ;
      if(ok==1) 
       {  for(i=0; i<n ; i++)   cout<<a[i]<<" " ;
          cout<<endl ;                   
       }
       if( a[0]!=1) return 0;

      while(next_permutation(a,a+n)); 
    }

    *****************************************************************

    #include <iostream>
    #include <algorithm>
    #include <string>

    using namespace std;

    int main()
    {
     string str;
     cin>>str ;
     sort(str.begin(),str.end());
     cout<<str<<endl;
     while(next_permutation(str.begin(),str.end()))
    {
      cout<<str<<endl; 
    }
    }


    *************************************************

    #include <iostream>
    #include <algorithm>
    int a[10];
    #include <string>
     
    using namespace std;
     
    int main()
    {
        int i,n ;
        cin >> n;
        for(i=0; i<n;i++)  a[i]=i+1;
        do
        {   for(i=0; i<n;i++) cout<<a[i]<<" " ;
         cout <<  endl;
        }
        while (next_permutation(a,a+n));
       
    }


    ****************************************************************


    #include <iostream>
    #include <algorithm>
    int a[10];
    #include <string>
     
    using namespace std;
     int main()
    {
        int i,n ,j,ok;
        cin >> n;
        for(i=0; i<n;i++)  a[i]=i+1;
        do
        {   ok=1;
     
      for(j=0; j<n;j++) cout<<a[i]<<" " ;
         cout <<  endl;
        }
        while (next_permutation(a,a+n));
       
    }

  • 相关阅读:
    Split Temporary Variable
    Introduce Explaining Variable
    Replace Temp with Query
    Extract Method
    自测代码的价值
    代码的坏味道
    Divergent Change & Shotgun Surgery
    Large Class
    Long Method
    Duplicated Code
  • 原文地址:https://www.cnblogs.com/wc1903036673/p/3231231.html
Copyright © 2011-2022 走看看