Posted
Filed under 공부한 것들/기타

[CODE type=vhdl]
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all; entity exadd is
  Port ( put1 : in std_logic_vector(3 downto 0);
          put2 : in std_logic_vector(3 downto 0);
          addsu : out std_logic_vector(3 downto 0));
end exadd;architecture ex of exadd is begin
process (put1, put2)
  begin
 
  if put1 > put2 then
     addsu <= put1 + put2;
      else
     addsu <= put2 - put1;
 
  end if;
  end process;
end ex;
[/CODE]

입력받는 두 수를 비교해서..
입력 받은 두 수와 덧셈, 뺄셈 하는 것..

시뮬레이터 결과:


※ VHDL 조낸 싫다..
2006/10/13 13:36 2006/10/13 13:36
Posted
Filed under 공부한 것들/C/C++
#include  
#define snum 5 

int tot[snum]={0}, rank[snum]={0}; 

int mrank()
{   
  int i,j;   
  rank[0] = 1;   

  for ( i = 1; i < snum; i++ )    
    rank[i] = 1; 

  for ( i = 1; i < snum; i++ ){ 
   for( j=0; j < i; j++ ){ 
    if ( tot[i] > tot[j] ){
      //rank[i] = rank[j]; 
      rank[j]++; 
    } else { 
      rank[i]++; 
    } 
  } 
} 
  return 0; 
} 

void main( ){ 
  int kuk[snum], eng[snum], mat[snum], k; 
  float ava[snum]={0}; 
  char name[snum][10]; 
  int i=0; 

  for(i=0; i < snum; i++) { 
    printf("성명:"); 
    scanf("%s", name[i]); 
    printf("국어:"); 
    scanf("%d", &kuk[i]); 
    printf("영어:"); 
    scanf("%d", &eng[i]); 
    printf("수학:"); 
    scanf("%d", &mat[i]); 
    tot[i] = kuk[i] + eng[i] + mat[i]; 
    ava[i] = tot[i] / 3.0f; } k = mrank(); 
    printf("----------------------------------------------------------------------");
    printf("성명 국어 영어 수학 총점 평균 순위"); 
    printf("----------------------------------------------------------------------");
    
    for(i=0; i < snum; i++) { 
      printf("%-10s %-3d %-3d %-3d %-3d %-7.2f %d", name[i], kuk[i], eng[i],mat[i],tot[i], ava[i],rank[i]); 
    } 
    printf("----------------------------------------------------------------------"); 
} 
2005/10/20 15:47 2005/10/20 15:47