Data Structures and Algorithms (English) - 6-9 Sort Three Distinct Keys(20 分)

简介: Data Structures and Algorithms (English) - 6-9 Sort Three Distinct Keys(20 分)

题目链接:点击打开链接

题目大意:略。

解题思路:考查enum类型与int类型的转换,详情:C/C++ - enum 与 int 相互转换

AC 代码

voidMySort( ElementTypeA[], intN )
{
intfcnt, tcnt, mcnt;
fcnt=tcnt=mcnt=0;
for(inti=0;i<N;i++)
    {
if(A[i]==false) fcnt++;
elseif(A[i]==true) tcnt++;
elseif(A[i]==maybe) mcnt++;
    }
for(inti=0;i<fcnt;i++) A[i]=false;
for(inti=fcnt;i<fcnt+mcnt;i++) A[i]=maybe;
for(inti=fcnt+mcnt;i<N;i++) A[i]=true;
}
目录
相关文章
Data Structures and Algorithms (English) - 6-10 Sort Three Distinct Keys(30 分)
Data Structures and Algorithms (English) - 6-10 Sort Three Distinct Keys(30 分)
104 0
Data Structures and Algorithms (English) - 6-13 Topological Sort(25 分)
Data Structures and Algorithms (English) - 6-13 Topological Sort(25 分)
112 0
Data Structures and Algorithms (English) - 6-4 Reverse Linked List(20 分)
Data Structures and Algorithms (English) - 6-4 Reverse Linked List(20 分)
121 0
Data Structures and Algorithms (English) - 6-6 Level-order Traversal(25 分)
Data Structures and Algorithms (English) - 6-6 Level-order Traversal(25 分)
105 0
Data Structures and Algorithms (English) - 6-2 Two Stacks In One Array(20 分)
Data Structures and Algorithms (English) - 6-2 Two Stacks In One Array(20 分)
144 0
Data Structures and Algorithms (English) - 7-12 How Long Does It Take(25 分)
Data Structures and Algorithms (English) - 7-12 How Long Does It Take(25 分)
114 0
Data Structures and Algorithms (English) - 6-8 Percolate Up and Down(20 分)
Data Structures and Algorithms (English) - 6-8 Percolate Up and Down(20 分)
105 0
Data Structures and Algorithms (English) - 6-15 Iterative Mergesort(25 分)
Data Structures and Algorithms (English) - 6-15 Iterative Mergesort(25 分)
191 0
Data Structures and Algorithms (English) - 6-1 Deque(25 分)
Data Structures and Algorithms (English) - 6-1 Deque(25 分)
101 0
Data Structures and Algorithms (English) - 6-14 Count Connected Components(20 分)
Data Structures and Algorithms (English) - 6-14 Count Connected Components(20 分)
145 0