Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <conio.h>
- #include <stdlib.h>
- #define TRUE 1
- void Menu(char *option);
- void MENU_Codificar(char *input);
- void Read_Word(char *input);
- int main() {
- char input[255], option;
- option = input[0] = '\0';
- while(TRUE) {
- Menu(&option);
- Read_Word(input);
- if(option == 'q')
- MENU_Codificar(input);
- //TODO: Menu de descodificar
- }
- return 0;
- }
- void Menu(char *option) {
- printf("\t\t Menu Principal\n");
- printf("\tq - Codificar\n");
- printf("\tw - Descodificar\n");
- while(*option != 'q' && *option != 'w') {
- fflush(stdin);
- *option = getch();
- }
- system("cls");
- }
- void MENU_Codificar(char *input) {
- char word_out[255];
- int idx, control, comp;
- comp = strlen(input);
- control = 1;
- for(idx=0; idx < comp;idx++, control++) {
- if(control % 2 != 0)
- word_out[idx] = *(input+idx);
- else
- word_out[comp-idx] = *(input+idx);
- }
- word_out[idx+1] = '\0';
- system("cls");
- printf("Palavra original: %s\n", input);
- printf("Palavra codificada: %s\n", word_out);
- system("cls");
- }
- void Read_Word(char *input) {
- printf("Palavra: ");
- gets(input);
- system("cls");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement