The length of the sequence is no more than 100 characters. It is considered that the sequence is read all, if 100 characters have already been read, or any other number of elements specified in advance by the user. Split the sequence into groups of 5 characters (in the last group, how many remain) and output each sequence in the reverse order.
Since we just started to study C, then there is almost no information on the Internet about how to do this by simple operators like the scan. I have presented an algorithm, but the program gives an incorrect answer, maybe you can figure out where the error is
#include #include #include #include #define N 100 int main() { int i, n,a,b; char C[N]; setlocale(0, ""); printf("ΠΠ²Π΅Π΄ΠΈΡΠ΅ ΠΊΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ²\n"); if (scanf("%d", &n) == 0) { printf("ΠΠ²Π΅Π΄Π΅Π½ ΡΠΈΠΌΠ²ΠΎΠ»\n"); getch(); return 0; } if (n > N || n <= 0) { printf("ΠΠ΅Π΄ΠΎΠΏΡΡΡΠΈΠΌΠΎΠ΅ ΡΠΈΡΠ»ΠΎ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ²\n"); getch(); return 0; } fflush(stdin); printf("ΠΠ²Π΅Π΄ΠΈΡΠ΅ ΠΌΠ°ΡΡΠΈΠ² ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ²\n"); for (i = 0; i < n; i++) { scanf("%c", &C[i]); } printf("ΠΡ Π²Π²Π΅Π»ΠΈ: \n"); for (i = 0; i < n; i++) { printf("%c ", C[i]); } printf("\nΠΠ»Π΅ΠΌΠ΅Π½ΡΡ ΠΏΠΎΡΠ»Π΅ ΡΠΎΡΡΠΈΡΠΎΠ²ΠΊΠΈ \n"); for (i = 0; i < n; i++) if (i+4 <= n) { a = i+4; for (a; a > i; a--) { printf("%c ", C[a]); } } else { a = i; for (n; n > a; n--) { printf("%c ", C[n]); } } getch(); return 0; }