此代码的问题在于,在用户在命令行中输入某些文本后,它实际上不会打印任何内容.
代码的目的是接受用户在文件名后通过命令提示符输入的行数.然后用户将输入内容进行反转.该程序应该反转每行的用户输入.
示例输入=大红狗
示例输出=狗红大
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define SIZE 80
char * reverseWords(char *string);
//argc is the count of cmd arguments.
//each command line argument is of type string
int main(int argc, char *argv[]){
//initialize local variables
int i;
int N;
char str[SIZE];
for(i = 1; i <argc; i++)
{
//set N equal to the users number in the command line
N = atoi(argv[i]);
}
if(argc != 2){//2 means that something is in the argument. …Run Code Online (Sandbox Code Playgroud) 我可以遍历字母表,但我正在尝试保留最后一次迭代并添加下一个字母.这是我的代码.
for(char alphabet = 'a'; alphabet <='z'; alphabet ++ )
{
System.out.println(alphabet);
}
Run Code Online (Sandbox Code Playgroud)
我希望它打印出看起来像这样的东西.
一个
AB
ABC
A B C D
abcde .....等等.这怎么可能?
这是我的代码.我不确定我是否需要一个计数器才能工作.答案应该是'iiii'.
def eliminate_consonants(x):
vowels= ['a','e','i','o','u']
vowels_found = 0
for char in x:
if char == vowels:
print(char)
eliminate_consonants('mississippi')
Run Code Online (Sandbox Code Playgroud)