分类: 计算机 Computer

  • VHDL问题整理

    Specify a legal end time

    仿真的时候,设置输入信号时间,得到提示:Specify a legal end time
    问题原因:仿真文件的总时间没有设置正确(过短)
    解决方法: 菜单Edit->end time,把仿真的总时间调长就OK了。

    —–

    取余数

    一般编程语言都是用‘%’来取余数的,而VHDL的取余符号是‘mod’。
    用法示例 reminder := a mod b;

    —-

    判断语句错误

    Debug了半天,都显示编译错误,我感觉IF语句的嵌套都是正确的呀。
    原来,VHDL的‘else if’是写成‘elsif’的,唉。
    所以,判断语句应该这么写:
    If
    sth;
    elsif
    sth;
    else
    sth;
    end if;

  • 用VBA编程提高Excel(WPS表格)效率

    不幸被抓住整理数据,6K行数据,上百列,纯手动的话估计手残了。
    发现本地球还存在VBA此等神器,成功救赎。
    本文只是简单演示VBA的威力,详细使用方法,请自行搜索“Excel VBA 手册”(WPS也通用)

    ————————————————————————

    统计数据
    统计数据

    好,我们这里有一列5874行的数据。统计“你上过多少门课”,数据的形式是数字,单元格留白的表示没有回答。
    我们想统计其中“上过1~10门课”的样品数。当然,除了VBA,你还可以用其他方法轻易把它弄出来,不过这里就先用这个简单的例子来演示VBA。

    1.在“开发工具”选项卡中打开VBA编辑器(WPS免费版用户是不带VBA功能的,VBA是收费软件)
    2.从表格可以看到,第2-5874行都是要处理的数据。
    3.在sheet1中键入代码,如下。

    Sub sub_dist()
        Dim c As Range '用于选定某一格
        Count = 0 '统计符合条件的样品数
        '对选定区域的每一格进行操作
        For Each c In Range("a2:a5875")
           If c.Value > 0 And c.Value <= 10 Then '如果当格数据满足大于0不超过10,则计数加1
           Count = Count + 1
           End If
       Next c
          Range("a5875").Value = Count '在a5875这一格显示统计数据
          
    End Sub
    
    代码
    代码

    4. 点击上方的运行按键,运行该函数。

    运行
    运行

    5. 结果就如你所愿,出现在了第5875行。

    结果
    结果

    ------------------
    VBA能使你从大量的枯燥工作中解脱出来,让你有更多时间做更多有意义的事。
    网上可以搜索到大量VBA教程~Keep learning!

  • 北邮IPTV无法播放 解决方法

    问题描述:
    Windows Media Player 错误:

    无法播放此文件,因为不支持指定的协议。如果在“打开 URL”对话框中键入了 URL,请尝试使用其他传输协议(例如“http:”或“rtsp:”)

    解决办法:

    开始>cmd (用管理员身份运行)。

    输入:regsvr32 wmnetmgr.dll
    重启计算机。

  • 全排列数 in C++

    台大学生出的机率题~好有创意的说
    台大学生出的机率题~好有创意的说

    遇到《机率课》这么一道作业题。

    除了枚举,我是没想到任何方法。

    欲用程序解决之,用1~8表示每朵花的漂亮程度,8为最美,但要求{1,2,3,4,5,6,7,8}全排列的算法,实在看得晕。

    全排列的意思:例如有{1,2,3},则它可以有以下排列{1,2,3},{1,3,2},{2,1,3}{2,3,1}{3,1,2}{3,2,1}.

    要用枚举解出上面的概率题,则先要把1到8的所有排列举出,判断每一个排列是否能让柏拉图找到最美丽的花。

    发现C++标准库里,有求全排列的算法。algorithm包里的next_permutation函数,可以列举数组的每个排列。

    #include      // std::cout
    #include     // std::next_permutation, std::sort
    using namespace std;
    
    int myints[] = {1,2,3,4,5,6,7,8}; // Represents the flowers. Rank 8 means the most beautiful one.
    int success_times = 0; // Record how many times are succeed.
    
    // This function checks if the current array can make platon succeed to find the most beautiful flower.
    // if it does, increse the success_times by 1 and return true, otherwise return false.
    bool check_succeed(){
    	int biggest_num_in_first_three = 0;
    	// Get the biggest number in the first three places.
    	for(int i=0; i<3; i++){
    		if(myints[i]>biggest_num_in_first_three) biggest_num_in_first_three = myints[i];
    	}
    	if (biggest_num_in_first_three == 8) return false;
    	
    	// Find the first number that bigger than the biggest_num_in_first_three;
    	int result = 0;
    	for(int i=3; i<8; i++){
    		if(myints[i]>biggest_num_in_first_three){
    			result = myints[i];
    			break;
    		}
    	}
    	if(result == 8){
    		success_times++;
    		return true;
    	}
    	return false;
    }
    
    int main () {
    
      sort (myints,myints+8);
      do {
      check_succeed();
      } while ( std::next_permutation(myints,myints+8) );
    
      cout << success_times<<'\n';  // Print out success times.
      cout << (float)success_times/(8*7*6*5*4*3*2*1); // Print out the probability.
    
      return 0;
    }
    
  • Chrome不能上网,但是IE可以。

      问题描述:

    1. Chrome不能上网。

    2. IE能正常上网,QQ能使用。

    3. Chrome提示,SOCKET NOT CONNECTED.

     

      解决方法:

    重置Windows SOCKET.

    1. 运行命令行,在开始菜单运行cmd.

    2. 在命令行模式,输入netsh winsock reset , 回车执行。

    3. 重启计算机。