Write the statements, including loop, to read in a sequence of positive integers and display the sequence after deleting adjacent repeated values. Use negative integer to terminate the loop. For example, if the user enters the following sequence:
12 16 16 8 22 55 55 55 19 16 42 -1
the output will be
12 16 8 22 55 19 16 42
Pleas do help me with this problem..
this is my source code..
12 16 16 8 22 55 55 55 19 16 42 -1
the output will be
12 16 8 22 55 19 16 42
Pleas do help me with this problem..
this is my source code..
Code:
#include <iostream> #include <cstdlib> using namespace std; int main() { int array_num[100]; int temp,index_array,breaker; index_array = 0; cout << "Enter your numbers : "; do { int input; cin >> input; input = breaker; if (input != temp) { array_num[index_array] = input; index_array++; temp = input; } else { continue; } } while (breaker != -1); int i; for (int i = 0; i < index_array; i++) { cout << array_num[i]; } char freeze; cin >> freeze; return 0 ; }
Comment