| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2181 人关注过本帖
标题:求a+aa+aaa+ ……a……aaa(n个a)的值
只看楼主 加入收藏
梦幻情缘
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:769
专家分:20
注 册:2005-4-4
收藏
 问题点数:0 回复次数:15 
求a+aa+aaa+ ……a……aaa(n个a)的值
using System;
class jisuan
{
	static void Main()
	{
		Console.WriteLine ("请你输入a的值:");
		long a=long.Parse (Console.ReadLine ());
		Console.WriteLine ("请你输入n的值:");
		long n=long.Parse (Console.ReadLine ());
		long sum=0;
		for(long m=1;m<=n;m++)
		{

			long i=0;
			long d=a;
			for(long b=1;b<=m;b++)
			{

				i+=d;
				d*=10;

			}
			sum+=i;
		}
		Console.WriteLine ("你所计算的结果是:"+sum);
		System.Threading .Thread .Sleep (80000000);
	}
}
搜索更多相关主题的帖子: aaa long Console sum 
2005-04-06 16:03
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
楼主多出点题啊。我明天早上自己做

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-04-06 16:09
梦幻情缘
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:769
专家分:20
注 册:2005-4-4
收藏
得分:0 
好呀,你看看这个网址. http://soft.nyist.net/zhanying/
2005-04-06 19:54
adm_qxx
Rank: 1
等 级:新手上路
帖 子:92
专家分:0
注 册:2005-4-5
收藏
得分:0 
楼主;sum只是64位整型
我要是让a=1;n=1000;
它怎么表示的了啊.

学习是进步的基础.
2005-04-07 08:41
幻风幻云
Rank: 1
等 级:新手上路
帖 子:762
专家分:0
注 册:2005-1-14
收藏
得分:0 
这个程序有人验证过结果吗?

2005-04-07 09:36
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
我。
我输了2。结果是12。正确。嘎嘎

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-04-07 09:59
幻风幻云
Rank: 1
等 级:新手上路
帖 子:762
专家分:0
注 册:2005-1-14
收藏
得分:0 
辛苦了
另一个也验证下吧

2005-04-07 10:13
梦幻情缘
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:769
专家分:20
注 册:2005-4-4
收藏
得分:0 
不好意思,将long变成int的形式就行了.
2005-04-07 10:15
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
不行的。还是要给N加个范围

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-04-07 10:16
梦幻情缘
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:769
专家分:20
注 册:2005-4-4
收藏
得分:0 
using System;
class jisuan
{
 static void Main()
  {
  Console.WriteLine ("请你输入a的值:");  
  int a=int.Parse (Console.ReadLine ());
  Console.WriteLine ("请你输入n的值:");  
  int n=int.Parse (Console.ReadLine ());  
  int sum=0;  
  for(int m=1;m&lt;=n;m++)  
      {  
       int i=0;  
       int d=a;  
       for(int b=1;b&lt;=m;b++)   
       {   
        i+=d;   
        d*=10;  
       }   sum+=i;  
      }  
  Console.WriteLine ("你所计算的结果是:"+sum);
  System.Threading .Thread .Sleep (80000000);
 }
}
2005-04-07 10:18
快速回复:求a+aa+aaa+ ……a……aaa(n个a)的值
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015759 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved