int main() {

    int multsof3[333];
    int multsof5[199];
    int dupes[200];
    int i, j, output;

    for (i = 1; i < 334; i++) {
        multsof3[(i-1)] = 3*i;
    }

    for (j = 1; j < 200; j++) {
        multsof5[(j-1)] = 5*j;
    }

    removedupes(multsof3, i-1, multsof5, j-1, dupes);
    output = sumlist(multsof3, i-1) + sumlist(multsof5, j-1) - sumlist(dupes, j-1);
    printf("The sum of all multiples of 3 and multiples of 5 below a thousand is: %d", output);



    /*	printf("Checking sumlist function: \n");
    	int temp = 0;
    	int list[6] = {3,6,9,12,15,18};
    	temp = sumlist(list, 6);
    	printf("The sum of list should be 63, but it is reported as %d\n", temp);
    */

    /*
    	// Checking remove dupes:
    	int i = 0;
    	int list1[11] = {3,6,9,12,15,18,21,24,27,30,33};
    	int list2[6] = {5,10,15,20,25,30};
    	int dupes[6] = {0,0,0,0,0,0};
    	removedupes(list1, 11, list2, 6, dupes);
    	for(i = 0; i<6; i++){
    		printf("The %d th dupes array is: %d\n", i, dupes[i]);
    	}
    	printf("The sum should be 258\n");
    	printf("The sum is in fact: %d", (sumlist(list1,11)+sumlist(list2,6)-sumlist(dupes,6)) );

    */
    return 0;




}
Ejemplo n.º 2
0
Table with_tot(const Table& T) {
	Table M = T;
	for (int i=0; i<M.size(); i++) M[i].push_back(sumlist(M[i]));
	return M;
}