所以当我做这样的事情时
0. Exit
1. list item one
2. list item two
3. list item three
4. list item four
并按照这样打印
#include<stdio.h>
#include<malloc.h>
int main()
{
int input, digit, temp, sum = 0;
printf("Enter Input Number :\n");
scanf("%d",&input);
temp = input;
//first find how many digits are there
for(digit = 0 ; temp != 0 ;digit++, temp /= 10);
//create one array equal to no of digits, use dynamic array because once you find different digits you can re-allocate memory and save some memory
int *p = malloc(digit * sizeof(int));
//now store all the digits in dynamic array
p[0] = input % 10;//1
for(int i = 0; i < digit ;i++) {
input /= 10;
p[i+1] = input %10;
if(p[i] != p[i+1])
sum = sum + p[i];
}
printf("sum of different digits : = %d \n",sum);
free(p);
p = 0;
return 0;
}
我得到
的结果A = [[1,2,3],
[4,5,6],
[7,8,9]]
所以我的问题是,如何将0放在首位?
我的假设是,它正在对char 0进行哈希处理,并且因为它的ascii值较低而将它放入一个桶中
答案 0 :(得分:5)
F#&#39; s Map
是使用二叉搜索树(特别是AVL树,我相信)实现的,而不是哈希映射。迭代二叉搜索树深度优先为您提供按排序顺序的项目。