# Homework help

• 05-06-2003
RoD
Homework help
Ok so heres the idea. She gives us a specified input and output, and we have to create the program that reads in the 5 values into an array and sorts them to reach the output. Simple enough as we have done plenty of these, but i cant figure out this pattern. The program below works but we cant use direct assignments, how is she getting this output????

Input: 3, 15, 34, 21, 84
Output: 0, 100, 100, 100, 100

My code:

Code:

```#include "stdafx.h" #include <iostream> using namespace std; const int ARRAY_MAX = 5; int main(int argc, char* argv[]) {         int intArray[ARRAY_MAX];         int temp;         for (int i = 0; i < ARRAY_MAX; i++)         {                 cout << "Enter an int value: ";                 cin >> intArray[i];         }         for (int j = 0; j < ARRAY_MAX; j++)         {                 if (intArray[j] < 10)                 {                         intArray[j] = 0;                 }                 else                 {                         intArray[j] = 100;                 }                 cout << intArray[j] << endl;         }         return 0; }```
• 05-06-2003
slaveofthenet
Nevermind, misunderstood the question.
• 05-06-2003
kuphryn
One solution is a set container.

Kuphryn
• 05-06-2003
RoD
Quote:

Originally posted by slaveofthenet
All it's doing is taking the 5 numbers and printing 0 for each number lower than 10, and 100 for each number larger than or equal to 10.
um i know i wrote that code. But the code uses direct assignment. I cant have arrayvalue = 100 or = 0; i have to manipulate it.
• 05-06-2003
RoD
She said theres a logical mathmatic solution, but guys i seriously cannot find it...any hints?
• 05-06-2003
golfinguy4
Code:

```        for (int j = 0; j < ARRAY_MAX; j++)         {                 while (intArray[j] < 10 && intArray[j]>0)                 {                         intArray[j]--;                 }                 while(intArray[j]>=10 && int Array<100)                 {                         intArray[j]++;                 }                 cout << intArray[j] << endl;         }```
• 05-07-2003
RoD
thnx man.