kmitl-profund-exercise/karaca-encode/main.cpp

30 lines
762 B
C++
Raw Permalink Normal View History

2023-04-02 18:10:40 +00:00
#include<stdio.h>
#include<iostream>
int main() {
char input[1000],reversed[1003];
printf("Input: ");
std::cin>>input;
printf("\n");
int length=0;
while(input[length]!='\0'){
length++;
}
for(int i=0;i<length;i++){
reversed[length-i-1]=input[i];
}
for(int i=0;i<length;i++){
if(reversed[i]=='a') reversed[i]='0';
else if(reversed[i]=='e') reversed[i]='1';
else if(reversed[i]=='i') reversed[i]='2';
else if(reversed[i]=='o') reversed[i]='3';
else if(reversed[i]=='u') reversed[i]='4';
}
reversed[length]='a';
reversed[length+1]='c';
reversed[length+2]='a';
reversed[length+3]='\0';
std::cout<<"Output: "<<reversed<<std::endl;
return 0;
}