I am trying to get a program to read a set of numbers from user input, and then from there manipulate the numbers and display messages depending on what numbers are present.
For consecutive numbers I have thought of minus-ing one number from the other, then the difference would be 1, so consequently they would be consecutive. Or could do the highest number minus the lowest number.
Now the problem I am having is I am unsure on how to get the code to read specific values of the array. The values of the array are obtained from user input.
Here is the part of my code that I think would assist you in helping me identify how to target specific values within the array.
Code:#include<stdio.h>int main(void)
{
int c;
int n;
int count1[127] = {0};
int count2[127] = {0};
int i;
int a;
char array[127];
char array1[127];
n = 5;
for (c = 0; c < n; c++) {
scanf(" %c %c ", &array1[c], &array[c]);
}
for (i = 0; i < n; i++) {
count1[array[i]]++; //if array[i] is N, then count1[N]++//
}
for (i = 0; i < 127; i++) {
if (count1[i] == 5) {
printf("Flush.\n");
}
}
for (a = 0; a < n; a++) {
count2[array1[a]]++; //if array[a] is N, then count1[N]++//
}
for (a = 0; a < 127; a++) {
if (count2[a] == 5) {
printf("Flush.\n");