0

I have to write a program to read 10 integers into an array. It will then read in one more integer. My program should then compute and output how many distinct pairs of integers in the array add up to the last number that was input. Note I cannot use the same number twice in a sum, unless it has been input two or more times.

How do I go about doing this?

2
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by Draghen
0

I really don't know how to go about doing this, I know that I have to have the program promt you to input 10 numbers, and then I have to get the program to compare all the possible sums of two of the integers and then say if they equal 9.

So far I have:

#include <iostream.h>
#include <stdlib.h>

int main()
{
int num, count;
int List[10],i;

// input 10 integers into an array and compute the average
for (i=0;i<10;i++)
{
cout << "Please enter an integer ";
cin >> List ;


But I don't know where to go from here

0

Maybe posting this to the (C++) forum will help.
If you want to do it in C#, then I suggest that you load a second array with unique integers from the first array, then sum the second array.

0

Thank you, I didn't even notice that I posted this in C#, I must of acciently pressed it. I ment to put it under C++. Thank you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.