二十五岁时我们都一样愚蠢、多愁善感,喜欢故弄玄虚,可如果不那样的话,五十岁时也就不会如此明智。
标题:C示例计算元音的程序
C示例计算元音的程序
#include <stdio.h> int main() { char s[] = "TajMahal"; // String Given int i = 0; int vowels = 0; // Vowels counter int consonants = 0; // Consonants counter while(s[i++] != '\0') { if(s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' ) vowels++; else consonants++; } printf("'%s' contains %d vowels and %d consonants.", s, vowels, consonants); return 0; }