让我们写一个c程序,不知道它做了什么...... [英] Let's write a c program, without knowing what it does...

查看:68
本文介绍了让我们写一个c程序,不知道它做了什么......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们写一个ac程序,不知道它做了什么...


你们中的一些人可能会记得Jim Roger的优秀系列帖子(关于
comp.programming)探索通用软件的实施

通过请求小型工作程序以不同语言进行的活动

作为来源。

好​​吧,思考&了解团队合作的好处,oss,

极限编程等我认为,而不是编写软件,而b $ b b具有已知目的 - 为什么不做相反的事情,写一个程序

的目的在它完成之前是不知道的!


有点像写一条线并将它传递给讲故事的游戏。


现在,我不确定这是否会给任何人注册有趣,或者如果它会b / b
会有效,但.....


我想让一些志愿者在下面的标准C程序中编写不详细的功能。




我选择了标准C,因为它是众所周知的并且交叉发布到clc

因为clc居民可以帮助挑选代码问题,也许还有

也有一些乐趣 - 或者只是质疑这个练习的无意义!

希望这不会冒犯clc的目的。


Just选择一个功能,无论你喜欢什么,a nd以任何你认为合适的方式编写函数
,以便它可以很好地适应下面简单的

程序,它越有想象力,它就越能伸展

鲁棒性和(希望)证明标准的价值和

结构化编程,或者其他东西..:


#include< stdio.h>

缺少
/ *函数定义! * /


int main()

{

int num1,num2,num3;


num1 = GetAnInteger();

num2 = GetAnInteger();


num3 = DoAnOperation(num1,num2);


DisplayResult(num3);


返回0;

}


注意返回整数的任何东西都必须返回一个有效的整数

,无论目标平台上的int大小如何。因此,b
选择''DoAnOperation''的人有一个额外的挑战,在设计一些有趣的东西时会产生有意义的回报(虽然它没有&br / >
*有*有意义!)。另外两个功能可能更容易,

但谁知道你可能会想出什么.....


无论功能的内容如何,我们都应该能够在符合iso标准的c / /
编译器上使用上面的任何组合编译任何组合并得到一个工作程序,即使我们从未计划过什么

它应该做的详细!

解决方案

gswork@mailcity.com (gswork)写道:

< snip>

到底是什么。

#include< stdio.h>

/ *缺少功能定义! * /


int DisplayResult(int num3)

{

PrepareResultForDisplay(& num3);

printf(FormatString(num3),num3);

}

int main()
{num / num int,num2,num3;

num1 = GetAnInteger();
num2 = GetAnInteger();

num3 = DoAnOperation(num1,num2);

DisplayResult( num3);

返回0;
}


无论目标平台上的int大小。因此,选择''DoAnOperation''的人在设计某事时会遇到额外的挑战




我会让其他人做那件事。


比尔,有趣有趣的有趣乐趣!


-

回复标题中的地址是正确的,但是如果你放弃usenet这个词,我会更快地阅读它。


2003年10月10日星期五12: 25:31 +0000,Bill Godfrey写道:

#include< stdio.h>

/ *函数定义失踪! * /
int DisplayResult(int num3)
{
PrepareResultForDisplay(& num3);
printf(FormatString(num3),num3);
}



int GetAnInteger()

{

if(CheckSomething()){

返回AskUserForANumber();

}

if(CheckSomethingElse()){

返回DoAnotherOperation(AskUserForanumber());

}

返回DoAnotherOperation(42);

}

int main()
{
int num1,num2,num3;

num1 = GetAnInteger();
num2 = GetAnInteger();

num3 = DoAnOperation(num1,num2);

DisplayResult(num3);

返回0;
}




-

NPV


大字打印,小字打印

Tom Waits - 向上走br />


bi * *** ******@bacchae.f9.co.uk.inva lid(Bill Godfrey)写道:

gs **** @ mailcity.com(gswork )写道:
< snip>
哎呀。
是的;为什么不。

#include< stdio.h>

/ *缺少功能定义! * /




#include< stdlib.h>


void PrepareResultForDisplay(int * qezcoatl)

{

if(qezcoatl == NULL)

{

fprintf(stderr,

" PrepareResultForDisplay在NULL指针上被阻塞。\ n");

退出(EXIT_FAILURE);

}

* qezcoatl = Clip(* qezcoatl, LowerLimit(),UpperLimit());

返回;

}

int DisplayResult(int num3)
{
PrepareResultForDisplay(& num3);
printf(FormatString(num3),num3);
}

int main()
{
int num1,num2,num3;

num1 = GetAnInteger();
num2 = GetAnInteger();

num3 = DoAnOperation(num1,num2);

DisplayResult(num3);

返回0;
}



无论如何目标平台上int的大小。因此,选择''DoAnOperation''的人在设计某些东西时会遇到额外的挑战



我会让别人去做那件事。
<比尔,有趣的有趣有趣的乐趣!




Irrwahn,没有riks没有fnu。

-

闭上眼睛,按三次逃生。


Let''s write a c program, without knowing what it does...

Some of you may recall Jim Roger''s excellent series of posts (on
comp.programming) exploring the implementation of common software
activities in different languages by requesting small working programs
as source.

Well, having thought & read about the benefits of teamwork, oss,
extreme programming etc i thought, instead of writing software that
has a known purpose - why not do the opposite, write a program the
purpose of which isn''t known until it''s done!

Kinda like the write a line and pass it along game of storytelling.

Now, i''m not sure if this will register as fun to anyone, or if it
will work out, but.....

I''d like some volunteers to write the functions that''s aren''t detailed
in the standard C program below.

I chose standard C because it''s well known and cross posted to c.l.c
because clc residents can help pick out code issues, and perhaps have
some fun too - or just question the pointlessness of this exercise!
Hope this doesn''t offend the purpose of clc.

Just pick one function, whatever you like, and write the function in
any way you see fit so that it will robustly fit into the simple
program below, the more imaginative it is, the more it will stretch
robustness and (hopefully) demonstrate the value of standards and
structured programming, or something..:

#include <stdio.h>

/* function definitions missing! */

int main()
{
int num1,num2,num3;

num1=GetAnInteger();
num2=GetAnInteger();

num3=DoAnOperation(num1, num2);

DisplayResult(num3);

return 0;
}

Note that anything that returns an integer must return a valid integer
whatever the size of int on the target platform. So the person who
chooses ''DoAnOperation'' has an extra challenge, in designing something
interesting that produces a meaningful return (though it doesn''t
*have* to be meaningful!). The other two functions might be easier,
but who knows what you may come up with.....

Regardless of the content of the functions, we should all be able to
compile any combination using the above on an iso standard compliant c
compiler and get a working program, even though we never planned what
it should do in detail!

解决方案

gs****@mailcity.com (gswork) wrote:
<snip>
What the heck.

#include <stdio.h>

/* function definitions missing! */
int DisplayResult(int num3)
{
PrepareResultForDisplay(&num3);
printf(FormatString(num3),num3);
}
int main()
{
int num1,num2,num3;

num1=GetAnInteger();
num2=GetAnInteger();

num3=DoAnOperation(num1, num2);

DisplayResult(num3);

return 0;
}
whatever the size of int on the target platform. So the person who
chooses ''DoAnOperation'' has an extra challenge, in designing something



I''ll let someone else do that part.

Bill, fun fun fun fun fun!

--
The address in the reply to header is correct, but I''ll
read it quicker if you drop the word "usenet".


On Fri, 10 Oct 2003 12:25:31 +0000, Bill Godfrey wrote:

#include <stdio.h>

/* function definitions missing! */
int DisplayResult(int num3)
{
PrepareResultForDisplay(&num3);
printf(FormatString(num3),num3);
}



int GetAnInteger()
{
if (CheckSomething()) {
return AskUserForANumber();
}
if (CheckSomethingElse()) {
return DoAnotherOperation(AskUserForANumber());
}
return DoAnotherOperation(42);
}

int main()
{
int num1,num2,num3;

num1=GetAnInteger();
num2=GetAnInteger();

num3=DoAnOperation(num1, num2);

DisplayResult(num3);

return 0;
}



--
NPV

"the large print giveth, and the small print taketh away"
Tom Waits - Step right up


bi**********@bacchae.f9.co.uk.invalid (Bill Godfrey) wrote:

gs****@mailcity.com (gswork) wrote:
<snip>
What the heck. Yep; why not.

#include <stdio.h>

/* function definitions missing! */



#include <stdlib.h>

void PrepareResultForDisplay( int *qezcoatl )
{
if ( qezcoatl == NULL )
{
fprintf( stderr,
"PrepareResultForDisplay choked on NULL pointer.\n" );
exit( EXIT_FAILURE );
}
*qezcoatl = Clip( *qezcoatl, LowerLimit(), UpperLimit() );
return;
}
int DisplayResult(int num3)
{
PrepareResultForDisplay(&num3);
printf(FormatString(num3),num3);
}

int main()
{
int num1,num2,num3;

num1=GetAnInteger();
num2=GetAnInteger();

num3=DoAnOperation(num1, num2);

DisplayResult(num3);

return 0;
}



whatever the size of int on the target platform. So the person who
chooses ''DoAnOperation'' has an extra challenge, in designing something



I''ll let someone else do that part.

Bill, fun fun fun fun fun!



Irrwahn, no riks no fnu.
--
Close your eyes and press escape three times.


这篇关于让我们写一个c程序,不知道它做了什么......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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