|
|
1.1 ! root 1: #print ! 2: Write a program that counts the number of vowels ! 3: in its input (excluding 'y'). Don't forget to define ! 4: the value of EOF at the beginning of your program. ! 5: #once #create Ref ! 6: This line contains some vowels, including ! 7: the letter 'y'. It also has a capital letter, I think. ! 8: #user ! 9: a.out <Ref >test ! 10: grep 28 test >/dev/null ! 11: #succeed ! 12: Here is one solution. ! 13: ! 14: #include <stdio.h> ! 15: ! 16: main() ! 17: { ! 18: int nv, c; ! 19: ! 20: nv = 0; ! 21: while ((c = getchar()) != EOF) ! 22: if (c=='a' || c=='e' || c=='i' || c=='o' || c=='u' ! 23: || c=='A' || c=='E' || c=='I' || c=='O' || c=='U') ! 24: nv++; ! 25: printf("%d\n", nv); ! 26: } ! 27: #fail ! 28: Did you remember capital letters? ! 29: #log ! 30: #next ! 31: 5.1f 10
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.