小编pew*_*pew的帖子

在c中反转数组 - 不会打印 -

此代码的问题在于,在用户在命令行中输入某些文本后,它实际上不会打印任何内容.

代码的目的是接受用户在文件名后通过命令提示符输入的行数.然后用户将输入内容进行反转.该程序应该反转每行的用户输入.

示例输入=大红狗

示例输出=狗红大

#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)

c arrays printf reverse fgets

6
推荐指数
1
解决办法
384
查看次数

for循环,通过字母表迭代?java的

我可以遍历字母表,但我正在尝试保留最后一次迭代并添加下一个字母.这是我的代码.

for(char alphabet = 'a'; alphabet <='z'; alphabet ++ )
        {

            System.out.println(alphabet);
        }
Run Code Online (Sandbox Code Playgroud)

我希望它打印出看起来像这样的东西.

一个

AB

ABC

A B C D

abcde .....等等.这怎么可能?

java iteration loops for-loop alphabet

4
推荐指数
3
解决办法
1万
查看次数

从Python中的字符串中删除辅音

这是我的代码.我不确定我是否需要一个计数器才能工作.答案应该是'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)

python string list python-idle python-3.x

3
推荐指数
2
解决办法
3794
查看次数

标签 统计

alphabet ×1

arrays ×1

c ×1

fgets ×1

for-loop ×1

iteration ×1

java ×1

list ×1

loops ×1

printf ×1

python ×1

python-3.x ×1

python-idle ×1

reverse ×1

string ×1