打印的一系列数字优化部分1的 [英] print a series of numbers optimization part 1

查看:162
本文介绍了打印的一系列数字优化部分1的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以说,你想一个程序,将打印数字1-9一遍又一遍

lets say you want to make a program that will print the numbers 1-9 over and over again

123456789123456789123456789

123456789123456789123456789

我想最明显的方式做到这一点是使用一个循环

i guess the most obvious way to do it would be to use a loop

int number = 1;
while(true)
{
    print(number);
    number = number + 1;
    if(number > 9)
        number = 1;
}

在我往前走了,这是要做到这一点,最好的办法还是有这样做的一个比较常见的方式?

before i go any further, is this the best way to do this or is there a more common way of doing this?

推荐答案

最的很明显的方法是这样的:

for (;;)
{
    for (int i = 1; i < 10; ++i)
    {
        print(i);
    }
}

为什么你想要optifuscate它是超越我。输出将会使压倒任何类型的优化是无关紧要的计算。

Why you'd want to optifuscate it is beyond me. Output is going to so overwhelm the computation that any kind of optimization is irrelevant.

这篇关于打印的一系列数字优化部分1的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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