整理
最近整理,發現買的書好多沒有看啊...整理一下或許就可以來個寒假計畫了...應該是說,經過一個認真一半的暑假,更能了解如何在一個長期的假期創造出屬於自己的價值
Let's see how far we can go.
最近整理,發現買的書好多沒有看啊...整理一下或許就可以來個寒假計畫了...應該是說,經過一個認真一半的暑假,更能了解如何在一個長期的假期創造出屬於自己的價值
written by yen3 in 9:56 下午 0 comments
經過了一段時日於圖書館和宿舍來往奔波的日子,似乎有點習慣了,不過還是不喜歡讀書間,覺得還是很像集中營,哈,或許我的個性使然吧,不過昨日在宿舍一個晚上趕完所有作業,雖然品質會有所下降,但是專心的程度還是可以接受的,或許,想認真的態度才是影響最大...
--
我看到了在我開學貼在桌上的"持續努力"
written by yen3 in 9:36 上午 0 comments
昨日找老師聊天,表明我大二上感覺上自己事實上並沒有學習到我想學東西,並且表示我想離開的意願,我和老師都極為認同自主學習的高度重要性,一個人每天花在不相干的事物是有可能耗費不少時間,但是這又跟系上風氣有關,老師也知道我的處境,也給我很多很寶貴的建議,同時,他也給了我一個我從未想過的問題,你怎麼保證新環境是否會克服你的問題,應該是說,你對於你想去的新環境了解嗎,很顯然的,我的思考還需要完備性
---
人生,還有太多太多事要學習
written by yen3 in 11:26 上午 0 comments
最近要交作業才會真正認真的開始思考合併排序的好用之處,在網路上所參考到的碼較少為template實作之,所以花了一點小功夫改寫和包裝,也還算方便,以下程式碼不算是我寫的,我只是就古狗大神找到的C code改成template
型式,使用了vector,這樣子會使程式碼較為簡潔而較能夠專精於整個程式的運作程,對我而言是一個不錯的學習方式
template<class T>
void MergeSort(vector<T>& u){
merge_sort(u,0,u.size()-1);
}
template<class T>
void merge_sort(vector<T>& u,int low, int high){
if(high>low){
merge_sort(u,low,(low+high)/2);
merge_sort(u,(low+high)/2+1,high);
Merge(u,low,high);
}
}
template<class T>
void Merge(vector<T>& u, int low, int high){
vector<T> temp;
for(unsigned int i=low, j=(low+high)/2+1 ; i<=(low+high)/2 || j<=high;){
if(i>(low+high)/2) temp.push_back(u[j++]);
else if(j>high) temp.push_back(u[i++]);
else if(u[i]>u[j]) temp.push_back(u[j++]);
else if(u[i]<u[j]) temp.push_back(u[i++]);
else{
temp.push_back(u[i++]);
temp.push_back(u[j++]);
}
}
for(unsigned int i=low,j=0;i<=high;i++,j++) u[i]=temp[j];
}
template<class T>
void QuickSort(vector<T>& u){
quicksort(u,0,u.size()-1);
}
template<class T>
void quicksort(vector<T>& u, int left, int right){
int l_hold=left, r_hold=right, p_pivot=0;
T pivot = u[left];
while(left<right){
while((u[right]>=pivot) && (left < right)) right--;
if(left!=right){
u[left] = u[right];
left++;
}
while((u[left]<=pivot) && (left<right)) left++;
if(left!=right){
u[right]=u[left];
right--;
}
}
u[left]=pivot;
p_pivot=left;
left = l_hold;
right = r_hold;
if(left<p_pivot) quicksort(u,left,p_pivot-1);
if(right>p_pivot) quicksort(u,p_pivot+1,right);
}
written by yen3 in 10:47 上午 0 comments
tag: programming
發現,原來VHDL好好玩..XD
貼上一個可能會錯的程式碼,今天要把實驗做到有趣極了為止,晚點再po上簡化程式碼
library ieee;
use ieee.std_logic_1164.all;
Use IEEE.std_logic_arith.all;
Use IEEE.std_logic_unsigned.all;
entity fulladder7 is port(integer1,integer2: in std_logic_vector(3 downto 0);
i1,i2,s1,s2:out std_logic_vector(0 to 6));
end fulladder7;
architecture a of fulladder7 is
signal temp_sum, temp_sub: std_logic_vector(4 downto 0);
signal temp_sum2:std_logic_vector(3 downto 0);
begin
process(integer1)
begin
case integer1 is
when "0000"=> i1 <="1111110";
when "0001"=> i1 <="0110000";
when "0010"=> i1 <="1101101";
when "0011"=> i1 <="1111001";
when "0100"=> i1 <="0110011";
when "0101"=> i1 <="1011011";
when "0110"=> i1 <="1011111";
when "0111"=> i1 <="1110010";
when "1000"=> i1 <="1111111";
when "1001"=> i1 <="1111011";
when others=> i1 <="0000000";
end case;
end process;
process(integer2)
begin
case integer2 is
when "0000"=> i2 <="1111110";
when "0001"=> i2 <="0110000";
when "0010"=> i2 <="1101101";
when "0011"=> i2 <="1111001";
when "0100"=> i2 <="0110011";
when "0101"=> i2 <="1011011";
when "0110"=> i2 <="1011111";
when "0111"=> i2 <="1110010";
when "1000"=> i2 <="1111111";
when "1001"=> i2 <="1111011";
when others=> i2 <="0000000";
end case;
end process;
process(integer1, integer2)
begin
temp_sum <= integer1 + integer2;
if temp_sum >= "01010" then
temp_sub <= temp_sum - "01010";
temp_sum2 <= "0001";
else
temp_sub <= temp_sum;
temp_sum2 <= "0000";
end if;
end process;
process(temp_sub)
begin
case temp_sub is
when "00000" => s1 <= "1111110";
when "00001" => s1 <= "0110000";
when "00010" => s1 <= "1101101";
when "00011" => s1 <= "1111001";
when "00100" => s1 <= "0110011";
when "00101" => s1 <= "1011011";
when "00110" => s1 <= "1011111";
when "00111" => s1 <= "1110010";
when "01000" => s1 <= "1111111";
when "01001" => s1 <= "1111011";
when others => s1 <= "0000000";
end case;
end process;
process(temp_sum2)
begin
case temp_sum2 is
when "0000" => s2 <= "1111110";
when "0001" => s2 <= "0110000";
when others => s2 <= "0000000";
end case;
end process;
end a;
written by yen3 in 12:05 下午 0 comments