TWISTER 2:继续阅读...... [英] TWISTER 2: Read on....
问题描述
TWISTER 2.1
??你必须在一个程序中做出决定,但是
编程语言的创建者忘了为程序员提供IF-ELE
构造?你能找到一份工作吗?
TWISTER 2.2
??你必须使用循环并打印1到100而不使用任何类型的
循环甚至GOTO语句?你能做到吗?
(* *)
************************* ***** 0oo *********(_)***** * oo0 ************************* *
最小的代码将被赏识
:)
Nirjhar Oberoi说:
TWISTER 2.1
??你必须在一个程序中做出决定,但是
编程语言的创建者忘了为程序员提供IF-ELE
构造?你能找到一份工作吗?
这取决于你认为IF-ELE应该做什么。就个人而言,我认为它应该从IF的值中减去ELE的值,从而产生两者之间的差额。解决方法如下:
diff = IF;
diff - = ELE;
TWISTER 2.2
??你必须使用循环并打印1到100而不使用任何类型的
循环甚至GOTO语句?你能做到吗?
我认为他不能。我不认为其他任何人都可以,因为使用
循环而不使用任何类型的循环可能会挑战即使是最聪明的程序员的聪明才智。尽管如此,打印
1到100而不使用任何类型的循环是微不足道的:
puts(1到100);
< blockquote class =post_quotes>
最小的代码将被认可
没问题。在这里你去:
main(){}
-
Richard Heathfield
Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk
电子邮件:rjh在上述域名中, - www。
Richard Heathfield写道:
Nirjhar Oberoi说:
.... snip ...
>
> ??您必须使用循环并打印1到100而不使用任何类型的循环甚至GOTO语句?你能做到吗?
我认为他不能。我不认为其他人也可以,因为
使用循环而不使用任何类型的循环可能会对即使是最聪明的程序员的聪明才智提出挑战。
尽管如此,打印1到100而不使用任何类型的循环
是微不足道的:
puts(" 1到100" );
你忘记了递归:
#include< stdio.h>
void putn(int n){
if(n - 1)putn(n - 1);
printf("%d \ n", n);
}
int main(void){putn(100);返回0;}
即使是所有人都可以使用。为什么人们给他们的孩子一个角色姓名?
-
Chuck F(cinefalconer at maineline dot net)
适用于咨询/临时嵌入式和系统。
< http://cbfalconer.home.att.net>
2006年11月23日21:40:06 -0800,Nirjhar Oberoi < ni ******* @ gmail.com>
写道:
> TWISTER 2.1
??您必须在程序中做出决定但是编程语言的创建者忘记为程序员提供IF-ELE
构造?你能找到一份工作吗?
你可以看一看当地的新闻报道,可能还有一些工作...... b $ b周围,你不会被要求做出决定。街头清扫?
也许
> TWISTER 2.2
??您必须使用循环并打印1到100而不使用任何类型的循环甚至GOTO语句?你能做到吗?
啊!这是VHDL,而不是C!关闭主题。
库循环;
使用loops.all;
print:std_logic_vector(1 to 100)=(其他=>''U'');
正如你所看到的,不仅是U,而且OTHERS也可以做到!
最小代码将被视为
尝试使用霍夫曼编码。
问候,
Zara
TWISTER 2.1
?? Your have to take a decision in a program but the creator of the
programming language forgot to supply the programmer with a IF-ELE
Construct? Can you find a work arround?
TWISTER 2.2
?? You have to use loops and print 1 to 100 without using any kind of
looping not even GOTO statement? Can u do it?
(* *)
******************************0oo*********(_)***** *oo0**************************
SMALLEST CODE WILL BE APPRECIATED
:)
Nirjhar Oberoi said:
TWISTER 2.1
?? Your have to take a decision in a program but the creator of the
programming language forgot to supply the programmer with a IF-ELE
Construct? Can you find a work arround?That depends on what you think IF-ELE should do. Personally, I think it
should subtract the value of ELE from the value of IF, yielding the
difference between the two. The workaround would be as follows:
diff = IF;
diff -= ELE;
TWISTER 2.2
?? You have to use loops and print 1 to 100 without using any kind of
looping not even GOTO statement? Can u do it?I don''t think he can. I don''t think anyone else can either, since using
loops without using any kind of looping is likely to challenge the
ingenuity of even the most perspicacious programmer. Nevertheless, printing
1 to 100 without using any kind of looping is trivial:
puts("1 to 100");
SMALLEST CODE WILL BE APPRECIATEDNo problem. Here ya go:
main(){}
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Richard Heathfield wrote:Nirjhar Oberoi said:
.... snip ...
>> ?? You have to use loops and print 1 to 100 without using any
kind of looping not even GOTO statement? Can u do it?
I don''t think he can. I don''t think anyone else can either, since
using loops without using any kind of looping is likely to
challenge the ingenuity of even the most perspicacious programmer.
Nevertheless, printing 1 to 100 without using any kind of looping
is trivial:
puts("1 to 100");You forgot about recursion:
#include <stdio.h>
void putn(int n) {
if (n - 1) putn(n - 1);
printf("%d\n", n);
}
int main(void) {putn(100); return 0;}
which even the all seeing u can use. Why do people give their
children one character names?
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
On 23 Nov 2006 21:40:06 -0800, "Nirjhar Oberoi" <ni*******@gmail.com>
wrote:
>TWISTER 2.1
?? Your have to take a decision in a program but the creator of the
programming language forgot to supply the programmer with a IF-ELE
Construct? Can you find a work arround?You may take a peek at local newspapaers, probably ther is some work
around, where you are not asked to make decisions. Street sweeping?
Maybe
>TWISTER 2.2
?? You have to use loops and print 1 to 100 without using any kind of
looping not even GOTO statement? Can u do it?Ah! that was VHDL, not C! Off Topic here.
library loops;
use loops.all;
print:std_logic_vector(1 to 100)=(others=>''U'');
As you can see, not only U, but also OTHERS can do it!
SMALLEST CODE WILL BE APPRECIATEDTry with Huffman coding.
Regards,
Zara
这篇关于TWISTER 2:继续阅读......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!