📄 l16.2c
字号:
#printWrite a program to read its input and find theword in it with the most vowels (instances of a,e,i,o, or u).Print out that word. Compile and test yourprogram, then type ready.#once #create RefWhen in the course of human events, it becomesnecessary for one people to dissolve the political bands which haveconnected them with another, and to assume among the powers of the earth the separate and equal station to whichthe laws of Nature and of Nature's God entitle them, a decentrespect to the opinions of mankind requires that they shoulddeclare the causes which impel them to the separation. We hold these truths to be self evident, that all menare created equal, that they are endowed by their creatorwith certain unalienable rights, that among these are life, liberty,and the pursuit of happiness. That to secure these rights,governments are instituted among men, deriving their justpowers from the consent of the governed. That wheneverany form of government becomes destructive of these ends,it is the right of the people to alter or to abolish it, andto institute new government, laying its foundation on suchprinciples and organizing its powers in such form, as to themshall seem most likely to effect their safety and happiness.#usera.out <Ref >xxxgrep unalienable xxx >/dev/null#succeed/* a way to find a word with lots of vowels */ #include <stdio.h>main(){ char bigword[100], thisword[100]; int nvow, maxvow, c, k; maxvow = k = 0; while ((c = getchar()) != EOF) { if (c == '\n' || c == ' ') { if (nvow > maxvow) { copy(thisword, bigword, k); maxvow = nvow; } nvow = k = 0; } else { thisword[k++] = c; switch (c) { case 'a': case 'e': case 'i': case 'o': case 'u': nvow++; } } } printf("the word %s had %d vowels\n", bigword, maxvow);}copy(a, b, n)char a[], b[];{ int i; for(i = 0; i < n; i++) b[i] = a[i]; b[i] = 0;}#log#next17.1a 10
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -