I am a programmer in learning and i have a problem.
I use visual studio 2015 and in language 'C' i have to make a program which entered array of char's sorts into ascending order, prints out only Roman numerals out of it ('I','X','V'...) and an array without those numerals. Total of 3 prints. I would really appreciate if someone would write down the code since i tried many times and failed to make it. Also try using only for's and if's since i can use those only .
Code example:
Code:#include <stdio.h> #define MAX_BR_EL 15 void main() { int i, p, j, s, n; while (1) { printf("Enter the array length:\n"); scanf("%d", &n); if (n <= 0 || n > MAX_BR_EL) break; char a[n]; printf("Enter the array:\n"); for (s = 0; s < n; scanf("%c", &a[s++])); { for (i = 0; i < n - 1; i++) for (j = i + 1; j < n; j++) if (a[i] < a[j]) { p = a[j], a[j] = a[i], a[i] = p; } } printf("Arranged array:\n", a[s]); } if (a[s] == 'I' || a[s] == 'V' || a[s] == 'X' || a[s] == 'L' || a[s] == 'C' || a[s] == 'D' || a[s] == 'M') { printf("Array of Roman numerals:\n"); printf("%c\n", a[s]); } else { printf("Array without Roman numerals:\n"); printf("%c\n", a[s]); } } }




Reply With Quote
