袁柱吧 关注:0贴子:15
  • 10回复贴,共1

现在 大二,计算机专业。

取消只看楼主收藏回复



1楼2015-11-20 11:10回复
    哈哈


    来自iPhone客户端2楼2015-11-23 00:52
    回复
      写一个 完整 的bash脚本 runtxt.sh ,功能:
      • (1)把文章里所有大写字母替换为小写,输出到
      en_low.txt
      • (2)统计en_low.txt的总词数,以空格为单位计算词。
      这个数字作为单独的一行输出到word_num.txt
      • (3)用sort


      3楼2015-12-09 09:50
      回复
        #!/bin/bash
        cat en_raw.txt | while read line
        do
        awk '{print tolower($line)}'tolower$line
        done
        ./a.sh >en_low.txts
        #!/bin/bash
        inputfile="en_low.txt"
        impfile="word_num.txt"
        cat $inputfile | tr ' ' '\n' > $impfile
        sort $impfile | uniq -c | sort -k/nr -k2


        4楼2015-12-16 09:51
        回复
          void CodeHuffman(HuffmanTree &T)
          {
          int *hc;
          cd[n-1]='\0';
          for(int i=0;i<=n;i++)
          {
          start=n-1;
          for(c=i,f=T.F[i].parent;f!=0;c=f,f=T.F[f].parent)
          {
          if(T.F[i].lchild==c) cd[--start]='0';
          else cd[--start]='1';
          }
          HC[i]=new ;
          strcpy(T.F,$cd[start]);
          }
          free(cd);
          }


          5楼2015-12-21 12:03
          回复
            1
            #!/bin/bash
            mkdir srcFrame
            cd srcFrame
            mkdir src
            mkdir bin
            mkdir lib
            mkdir data
            cd src
            touch main.c
            cd ..
            cd lib
            touch srcFrame.h
            2
            #!/bin/bash
            grep '科技' phone.txt | cut -d# -f2,4 | sort -t# -k1 > result.txt
            3
            #!/bin/bash
            sort gdp.txt -t: -nk3 -r | head -n20 > tm.txt
            4
            #include"stdio.h"
            #includ<iostream>
            using namespace std;
            int main()
            {
            int i=0;
            while(x!=110)
            {
            cout<<"ple input words:"<<endl;
            int x=rand();
            i=x%10;
            switch(i)
            {
            case 0: cout<<"he0"<<endl;break;
            case 0: cout<<"he0"<<endl;break;
            case 1: cout<<"he1"<<endl;break;
            case 2: cout<<"he2"<<endl;break;
            case 3: cout<<"he3"<<endl;break;
            case 4: cout<<"he4"<<endl;break;
            case 5: cout<<"he5"<<endl;break;
            case 6: cout<<"he6"<<endl;break;
            case 7: cout<<"he7"<<endl;break;
            case 8: cout<<"he8"<<endl;break;


            6楼2015-12-23 09:55
            回复
              #!/bin/bash
              echo "what would you like to know about me?"
              select question in name gender age nation college hometown high_school middle_school favorite_color favorite_things major quit
              do
              if [ $question = name ]
              then
              echo "My name is Yuanzhu."
              elif [ "$question" = gender ]
              then
              echo "Male"
              elif [ "$question" = age ]
              then
              echo "20"
              elif [ "$question" = nation ]
              then
              echo "han"
              elif [ "$question" = college ]
              then
              echo "BLCU"
              elif [ "$question" = hometown ]
              then
              echo "Inner Mongolia"
              elif [ "$question" = high_school ]
              then
              echo "Beishida jining fuzhong"
              elif [ "$question" = middle_school ]
              then
              echo "Datong shizhong"
              elif [ "$question" = favorite_color ]
              then
              echo "blue"
              elif [ "$question" = favorite_things ]
              then
              echo "Music and Travel"
              elif [ "$question" = major ]
              then
              echo "Computer Science and Technology"
              elif [ "$question" = quit ]
              then
              echo "quit"
              break
              else
              break
              fi
              done


              7楼2015-12-29 19:19
              回复
                !/bin/bash
                grep "Beijing" corpus.txt > out.txt


                8楼2015-12-29 21:05
                回复
                  1
                  #!/bin/bash
                  mkdir srcFrame
                  cd srcFrame
                  mkdir src
                  mkdir bin
                  mkdir lib
                  mkdir data
                  cd src
                  touch main.c
                  cd ..
                  cd lib
                  touch srcFrame.h
                  2
                  #!/bin/bash
                  grep '科技' phone.txt | cut -d# -f2,4 | sort -t# -k1 > result.txt
                  3
                  #!/bin/bash
                  sort gdp.txt -t: -nk3 -r | head -n20 > tm.txt
                  4
                  #!/bin/bash
                  echo "what would you like to know about me?"
                  select question in name gender age nation college hometown high_school middle_school favorite_color favorite_things major quit
                  do
                  if [ $question = name ]
                  then
                  echo "My name is Yuanzhu."
                  elif [ "$question" = gender ]
                  then
                  echo "Male"
                  elif [ "$question" = age ]
                  then
                  echo "20"
                  elif [ "$question" = nation ]
                  then
                  echo "han"
                  elif [ "$question" = college ]
                  then
                  echo "BLCU"
                  elif [ "$question" = hometown ]
                  then
                  echo "Inner Mongolia"
                  elif [ "$question" = high_school ]
                  then
                  echo "Beishida jining fuzhong"
                  elif [ "$question" = middle_school ]
                  then
                  echo "Datong shizhong"
                  elif [ "$question" = favorite_color ]
                  then
                  echo "blue"
                  elif [ "$question" = favorite_things ]
                  then
                  echo "Music and Travel"
                  elif [ "$question" = major ]
                  then
                  echo "Computer Science and Technology"
                  elif [ "$question" = quit ]
                  then
                  echo "quit"
                  break
                  else
                  break
                  fi
                  done
                  5
                  !/bin/bash
                  grep "Beijing" corpus.txt > out.txt
                  6
                  #!/bin/bash
                  cut mails.txt -d@ -f2 | uniq -c > sortmail.txt
                  7
                  #!/bin/bash
                  for (( i=1; i<=1000; i++ ))
                  do
                  echo $i | md5sum | head -c 6 >>rubbish.txt
                  echo -n "@" >>rubbish.txt
                  echo $i | md5sum | head -c 4 >>rubbish.txt
                  echo ".com" >>rubbish.txt
                  done
                  8,9,10
                  #!/bin/bash
                  grep San psm.txt
                  grep "^J" datafile
                  grep "700$" datafile
                  grep -v "834" datafile
                  grep [:::]12[:/:] datafile 或者 grep '\:12\/'datafile
                  grep -i [a-z][[:blank:]]k datafile
                  sed -e 's/Jon/Jonathan/ datafile
                  sed -n '5,10p' datafile
                  sed -e '/Lane/d' datafile
                  sed -e 's/^Fred/***Fred/' datafile
                  cat datafile | grep Popeye | sed -e 's/3\/19\/35/11\/14\/46/'
                  sed -e '/^$/d' datafile
                  awk -F ":" '{print $1}' datafile | awk '{print $2}'|awk '/^D/'
                  awk -F ":" '{print $1}' datafile | awk '{print $1}'|awk '/^[CE]/'
                  awk -F ":" '{print $1}' datafile | awk '{if(length($1)==4)print $1}'
                  awk -F ":" '/\[916\]/{print $1}' datafile
                  awk -F ":" '{print $1}' datafile | awk '{print $2,",",$1}'


                  9楼2015-12-29 23:44
                  回复
                    数字逻辑 序列发生器
                    library IEEE;
                    use IEEE.STD_logic_1164.all;
                    use ieee.std_logic_unsigned.all;
                    entity liuliuliu is
                    Port(
                    en,ck:in std_logic;
                    y:out std_logic);
                    end liuliuliu;
                    architecture pro of liuliuliu is
                    signal q:std_logic_vector(2 downto 0);
                    begin
                    process(en,ck)
                    begin
                    if(en='0')then
                    q<="000";
                    elsif(ck'EVENT AND ck='1')then
                    q<=q+1;
                    end if;
                    end process;
                    process(q)
                    begin
                    case q is
                    when "000"=>Y<='1';
                    when "001"=>Y<='0';
                    when "010"=>Y<='0';
                    when "011"=>Y<='0';
                    when "100"=>Y<='0';
                    when "101"=>Y<='0';
                    when "110"=>Y<='0';
                    when others=>Y<='1';
                    end case;
                    end process;
                    end pro;


                    10楼2016-06-20 17:05
                    回复
                      #页面置换算法
                      @numberArray=(2,3,2,1,5,2,4,5,3,2,5,2);
                      LRO(\@numberArray);
                      CLOCK(\@numberArray);
                      sub LRO
                      {
                      my($numArr)=@_;
                      print "*****LRO*****\n";
                      my $interrupt=0;
                      @array=();
                      for(my $i=0;$i<@{$numArr};$i++){
                      $flag=1;
                      for(my $j=0;$j<@array;$j++){
                      if( ${$numArr}[$i]==${$array[$j]}[0] ){
                      ${$array[$j]}[1]=$i;
                      $flag=0;
                      }
                      }
                      if($flag==1){
                      if(@array<3){
                      my @label=(${$numArr}[$i],$i);
                      push(@array,\@label);
                      $interrupt++;
                      }
                      else{
                      $min=100;
                      for(my $j=0;$j<@array;$j++){
                      if( ${$array[$j]}[1]<$min ){
                      $min=${$array[$j]}[1];
                      $pos=$j;
                      }
                      }
                      ${$array[$pos]}[0]= ${$numArr}[$i];
                      ${$array[$pos]}[1]= $i;
                      $interrupt++;
                      }
                      }
                      for(my $j=0;$j<@array;$j++){
                      print "${$array[$j]}[0] ";
                      }
                      print "\n";
                      #getc();
                      }
                      print "中断次数:$interrupt\n";
                      }
                      sub CLOCK
                      {
                      my($numArr)=@_;
                      print "*****CLOCK*****\n";
                      my $interrupt=0;
                      @array=();
                      $pointer=0;
                      for(my $i=0;$i<@{$numArr};$i++){
                      $flag=1;
                      for(my $j=0;$j<@array;$j++){
                      if( ${$numArr}[$i]==${$array[$j]}[0] ){
                      ${$array[$j]}[1]=(${$array[$j]}[1]+1)%2;
                      $flag=0;
                      }
                      }
                      if($flag==1){
                      if(@array<3){
                      my @label=(${$numArr}[$i],1);
                      push(@array,\@label);
                      $pointer=($pointer+1)%3;
                      $interrupt++;
                      }
                      else{
                      for(my $j=$pointer;;$j++){
                      $j=$j%3;
                      if( ${$array[$j]}[1]==0 ){
                      ${$array[$j]}[0]= ${$numArr}[$i];
                      ${$array[$j]}[1]= 1;
                      $pointer=$j+1;
                      $interrupt++;
                      last;
                      }
                      ${$array[$j]}[1]= 0;
                      }
                      }
                      }
                      for(my $j=0;$j<@array;$j++){
                      print "${$array[$j]}[0] ";
                      }
                      print "\n";
                      #getc();
                      }
                      print "中断次数:$interrupt\n";
                      }


                      11楼2017-06-19 11:38
                      回复