C# 求最小公倍数 为啥输出后 停不下来 怎么改

[复制链接]
查看11 | 回复3 | 2011-4-7 20:32:24 | 显示全部楼层 |阅读模式
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{

class Program

{

static void Main(string[] args)

{



while (true)

{

string s = Console.ReadLine();

if (string.IsNullOrEmpty(s))

break;

if (s == "EOF")

{ break; }

string[] ss = s.Split(' ');

int a = Convert.ToInt32(ss[0]);

int b = Convert.ToInt32(ss[1]);

for (int i = 1; i <= Math.Pow(2,31); i++)

if (i % a == 0 && i % b == 0)

{

Console.WriteLine(i);

}



}

}

}
}

回复

使用道具 举报

千问 | 2011-4-7 20:32:24 | 显示全部楼层
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{
class Program
{
static void Main(string[] args)
{
while (true)
{
string s = Console.ReadLine();
if (strin
回复

使用道具 举报

千问 | 2011-4-7 20:32:24 | 显示全部楼层
你运行的时候,不要直接调试,而是按CTRL + F5的。。或者在调试里面有一个,运行不调试的按钮的。。也是一样的。
回复

使用道具 举报

千问 | 2011-4-7 20:32:24 | 显示全部楼层
知道问题在哪里了!for (int i = 1; i <= Math.Pow(2,31); i++){
if (i % a == 0 && i % b == 0)
{
Console.WriteLine(i);
break;
}}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行