Exemple #1
0
int main(void){

	int i, j, num, *arr, *num1, * num2, result=0;
	
	scanf("%d", &num);

	arr = (int*)malloc(sizeof(int)*num);

	for(i=0; i<num; i++)
		scanf("%d", &arr[i]);

	num1 = genNum(arr, num,  3);
	num2 = genNum(arr, num,  2);

	for(i=0; i<pow((float)num, 3); i++){
		for(j=0; j<pow((float)num, 2); j++){
			result += count(num1[i], num2[j], arr, num);
		}
	}

	printf("%d\n", result);

	return 0;
}
Exemple #2
0
int main(int argc, char *argv[]) {
    std::cout << "Creating and printing fixed list of entries:\n";
    std::string words[] = {"one", "two", "three"};
    StrList l1 = {words, words + 1, NULL, words + 2, NULL};
    print(&l1);

#ifdef EX_PART2
    std::cout << "Generating and printing list of entries:\n";    
    // Now call generate numbers and print them.
    StrList l2;
    genNum(&l2, std::stoi(argv[1]));
    print(&l2);
    freeList(&l2);
#endif
    
    return 0;
}