zoukankan      html  css  js  c++  java
  • 临时代码保存

    12模拟链表,约瑟夫环。。来自一个失败的题意理解。。

    var
      a,b:array[0..10] of longint;
      n,i,t,k,j,p,m:longint;
    
    begin
      //readln(n);
      n:=10;
      for i:=1 to n do a[i]:=i;
      for i:=1 to n-1 do b[i]:=i+1;
      b[n]:=1;
      m:=0;
      t:=n;  
      repeat
        for j:=1 to 3 do begin
          p:=t;
          t:=b[t];  
        end;  
        b[p]:=b[t];
        inc(m);
      until m=8;
      writeln(b[p]);
      t:=p;
      for k:=1 to 20 do begin
        write( a[t],' ' );
        t:=b[t]; //
      end;
    end.
    View Code

    数组的STL快排:

    #include <iostream>
    #include <algorithm>
    using namespace std;
    
    int main()
    {
      int i,a[10];
      srand((int)time(0));
      for(i=0;i<10;i++)
      {
        a[i]=rand()%30;
        cout<<a[i]<<" ";
      }
      cout<<endl;
      sort(a,a+10);
      for(i=0;i<10;i++)
        cout<<a[i]<<" ";
      cout<<endl;
      return 0;
    }
    View Code

    复赛新模板:

    #include <stdio.h>
    #include <stdlib.h>
    #include <iostream>
    #include <string>
    #include <algorithm>
    using namespace std;
    int main()
    {  
      int i,j;
      //freopen("xxx.in", "r", stdin);
      //freopen("xxx.out", "w", stdout);
     
      //...
     
      //fclose(stdin); fclose(stdout);
      return 0;
    }
    View Code

    22

  • 相关阅读:
    python面试题之生成器迭代器
    python之初识函数二
    Python之初识函数一
    Python初识之文件操作
    python初识三
    python初识二
    python初识一
    2.15.5.menuconfig的使用和演示
    2.15.4.内核的配置原理1
    2.15.3.内核配置和编译体验
  • 原文地址:https://www.cnblogs.com/xin-le/p/4066308.html
Copyright © 2011-2022 走看看