首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

今天是学习C#第四天 大家伙儿还有更加简便,高效率的写法吗

2013-02-19 
今天是学习C#第四天 大家还有更加简便,高效率的写法吗?我还会继续努力,哈哈using Systemusing System.Col

今天是学习C#第四天 大家还有更加简便,高效率的写法吗?
我还会继续努力,哈哈今天是学习C#第四天 大家伙儿还有更加简便,高效率的写法吗
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
for (int a = 1; a <= 9;a++ )
{
for (int b = 1; b <= a;b++ )
{
Console.Write(a.ToString()+"*"+b.ToString()+"="+Convert.ToString( a*b)+"\t");
}
Console.WriteLine();
}
Console.ReadKey();
}
}
}

大家还有更加简便,高效率的写法吗?
[解决办法]

.386
.MODEL FLAT

ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD

INCLUDE io.h

cr      EQU     0dh
Lf      EQU     0ah

.STACK  4096

.DATA
prompt1     BYTE         cr,lf,lf,"The multiplication table is:",cr,lf,lf,0
number      BYTE         16 DUP (?)
cheng       BYTE         '*',0
deng        BYTE         '=',0
space       BYTE         ' ',0
hh          BYTE         cr,lf,0

.CODE

_start:
            mov         ax,0
            mov         bx,0

            mov         cx,1

            output      prompt1
one:
            mov         ax,cx
            inc          bx
            mul         bx
            itoa        number,cx
            output      [number+4]
            output      cheng;输出’*’
            itoa        number,bx
            output      [number+5]
            output      deng;输出‘=‘
            itoa        number,ax


            output      [number+4]
            output      space;输出空格
            cmp         bx,cx
            jb          one

            output      hh
            inc         cx
            cmp         cx,9
            ja          forEnd
            mov         bx,0
            jmp         one


forEnd:
            INVOKE  ExitProcess, 0
PUBLIC _start
            END


[解决办法]
楼主写的就已经很简单了。
[解决办法]
网络上搜索有多种写法可学,多学几种写法有益处.
[解决办法]
不知道lz所谓的“简洁”是不是想少写几行代码

Enumerable.Range(1, 9).SelectMany(t => Enumerable.Range(1, t).Select(tt => t + "*" + tt + "=" + tt * t + (tt==t?"\r\n":"\t"))).ToList().ForEach(t=>Console.Write(t));

[解决办法]
用上字符串格式化就好了,不然代码很难看。

热点排行