为什么它不起作用? [英] Why it doesn't work?

查看:79
本文介绍了为什么它不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include< stdio.h>


//如果char * frase =" Andrew"我想* frase =" werdnA"用这个...


int main()

{

int start,finish;

char aux;

char * phrase =" Andrew ...正在听Dimmu Borgir ..." ;;

finish = strlen(短语)-1 ;


for(start = 0; start< finish; start ++,finish--){

/ * Changing ... * /

aux = *(短语+开始);

*(短语+开始)= *(短语+结束);

*(短语+完成)= aux;

}

返回0;

}

解决方案

< blockquote>在文章< e0 ********** @ cormoran.emeteo.local>,

Olaf \El Blanco \ <已经****** @ yahoo.no>写道:

//如果char * frase =" Andrew"我想* frase =" werdnA"用这个...




你不打印算法的结果,所以你不能告诉我们b $ b告诉你是否有效。

-

有些想法错了,只有一个非常聪明的人才能相信他们。 - George Orwell


:)这不是整个程序......

" Walter Roberson" < RO ****** @ ibd.nrc-cnrc.gc.ca> escribióenel mensaje

news:e0 ********** @ canopus.cc.umanitoba.ca ...

文章< e0 * *********@cormoran.emeteo.local> ;,
Olaf \El Blanco \ <已经****** @ yahoo.no>写道:

//如果char * frase =" Andrew"我想* frase =" werdnA"用这个...



你不打印算法的结果,所以你不能告诉它是否有效。
-
有些想法错了,只有一个非常聪明的人才能相信它们。 - George Orwell



在文章< e0 ********** @ cormoran.emeteo.local>中,

Olaf \El Blanco \ <已经****** @ yahoo.no>写道:

" Walter Roberson" < RO ****** @ ibd.nrc-cnrc.gc.ca> escribióenel mensaje
新闻:e0 ********** @ canopus.cc.umanitoba.ca ...

文章< e0 ***** *****@cormoran.emeteo.local> ;,
Olaf \El Blanco \ <已经****** @ yahoo.no>写道:

> //如果char * frase =" Andrew"我想* frase =" werdnA"用这个...


你不打印算法的结果,所以你不能告诉它是否有效。


:)这不是整个程序...




然后发布一个示例,清楚地显示示例的代码

并描述你看到的结果。


因为你的代码中没有副作用,所以编译器允许使用

来完全优化它(除了返回代码。)


哦,并修复你的main声明,并找出如何

声明strlen()。

对于它的价值,我在输入一个put()后得到的输出是


.... rigroB ummiD ot gninetsil si ... werdnA


-

当时我还很年轻,但我也很朦胧。

- Christopher Priest


#include <stdio.h>

// If char *frase="Andrew" I want *frase="werdnA" with THIS for...

int main()
{
int start, finish;
char aux;
char *phrase="Andrew... is listening to Dimmu Borgir...";
finish=strlen(phrase)-1;

for (start=0; start<finish; start++, finish--) {
/* Changing... */
aux= *(phrase+start);
*(phrase + start) = *(phrase + finish);
*(phrase + finish) = aux;
}
return 0;
}

解决方案

In article <e0**********@cormoran.emeteo.local>,
Olaf \"El Blanco\" <ve******@yahoo.no> wrote:

// If char *frase="Andrew" I want *frase="werdnA" with THIS for...



You don''t print out the result of your algorithm, so you can''t
tell whether it worked or not.
--
There are some ideas so wrong that only a very intelligent person
could believe in them. -- George Orwell


:) This is not the whole program...
"Walter Roberson" <ro******@ibd.nrc-cnrc.gc.ca> escribió en el mensaje
news:e0**********@canopus.cc.umanitoba.ca...

In article <e0**********@cormoran.emeteo.local>,
Olaf \"El Blanco\" <ve******@yahoo.no> wrote:

// If char *frase="Andrew" I want *frase="werdnA" with THIS for...



You don''t print out the result of your algorithm, so you can''t
tell whether it worked or not.
--
There are some ideas so wrong that only a very intelligent person
could believe in them. -- George Orwell



In article <e0**********@cormoran.emeteo.local>,
Olaf \"El Blanco\" <ve******@yahoo.no> wrote:

"Walter Roberson" <ro******@ibd.nrc-cnrc.gc.ca> escribió en el mensaje
news:e0**********@canopus.cc.umanitoba.ca...

In article <e0**********@cormoran.emeteo.local>,
Olaf \"El Blanco\" <ve******@yahoo.no> wrote:

>// If char *frase="Andrew" I want *frase="werdnA" with THIS for...

You don''t print out the result of your algorithm, so you can''t
tell whether it worked or not.

:) This is not the whole program...



Well then post an example that shows clearly the code for the example
and describe the result you are seeing.

Because there are no side effects in your code, compilers are allowed
to optimize it out completely (except for the return code.)

Oh, and fix your declaration of main, and figure out how to
declare strlen().

For what it''s worth, the output I got after putting in a puts() was

....rigroB ummiD ot gninetsil si ...werdnA

--
I was very young in those days, but I was also rather dim.
-- Christopher Priest


这篇关于为什么它不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆