Δημοσιεύτηκε: 25 Αύγ 2011, 15:51
από stamatiou
Λοιπόν αυτό δεν το έχω ξαναδεί!

Spoiler: show
- Κώδικας: Επιλογή όλων
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int is_vowel(char c) {
int i;
char s[] = {'a','A','E','e','I','i','o','O','U','u','Y','y'};
for(i = 0;i<12;i++) {
if(c == s[i]) {
return 0;
}
}
return 1;
}
int is_consonant(char c) {
int i;
char s[] = {'b','B','c','C','d','D','f','F','g','G','h','H','j','J','k','K','l','L','m','M','n','N','p','P','q','Q','r','R','s','S','t','T','v','V','w','W','x','X','z','Z','\0'};
for(i = 0;i<40;i++) {
if(c == s[i]) {
return 0;
}
}
return 1;
}
int main(void) {
int i,i2 = 0,i3 = 0,i4 = 0;
char inbuf[256];
char vowel[255];
char consonant[255];
char other[255];
fgets(inbuf,256,stdin);
for(i=0;i<strlen(inbuf);i++) {
if(is_consonant(inbuf[i]) == 0) {
consonant[i2++] = inbuf[i];
}else if(is_vowel(inbuf[i]) == 0) {
vowel[i3++] = inbuf[i];
}else {
if(inbuf[i] > 31 && inbuf[i] <= 64) {
other[i4++] = inbuf[i];
}
}
}
for(i=0;i<strlen(inbuf);i++) inbuf[i] = 0;
strcat(inbuf,vowel);
strcat(inbuf,other);
strcat(inbuf,consonant);
for(i=0;i<strlen(inbuf);i++) printf("%c",inbuf[i]);
putchar('\n');
return 0;
}