| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2558 人关注过本帖
标题:计算几个数的和
只看楼主 加入收藏
梦幻情缘
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:769
专家分:20
注 册:2005-4-4
收藏
 问题点数:0 回复次数:21 
计算几个数的和

//你想计算几个数的和 using System; class he { public static void Main() { int i; double j; double sum=0; chongxin: Console.WriteLine("你想计算几个数的和?"); i=int.Parse(Console.ReadLine()); //所输入的数不能为负数 if(i<=0) { Console.WriteLine("你所输入的数是错误的,请重新输入!"); goto chongxin; } //for循环 for (int X=1;X<=i;X++) { Console.WriteLine("输入第"+X+"个数:"); j=double.Parse(Console.ReadLine()); sum+=j; } Console.WriteLine("你所求的数的和是:"+sum); bool c = true; while(c) { //是否要继续呢? jixu: Console.WriteLine("你还继续计算吗?Y/N"); string a; a=Console.ReadLine(); switch(a) { case "Y": case "y": goto chongxin; case "N": case "n": Console.WriteLine("再见了,同志."); c=false; break; default: //判断所输入的信息错误. Console.WriteLine("你所输入的信息有错误!请你重新输入."); Console.WriteLine(); c=true; //返回到jixu: goto jixu; } System.Threading.Thread.Sleep(20);

} } }

rEPSeUEv.txt (1.06 KB) 计算几个数的和

搜索更多相关主题的帖子: Console double int WriteLine 
2005-04-06 15:45
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:04
梦幻情缘
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:769
专家分:20
注 册:2005-4-4
收藏
得分:0 
谢谢夸奖啊!
2005-04-06 16:11
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:23
梦幻情缘
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:769
专家分:20
注 册:2005-4-4
收藏
得分:0 
当然了,这是以前写的,今天申请了个号,顺便就也传上去。
2005-04-06 16:25
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
学C#多久了啊。
应用程序开始编了吗

我是初学者,希望大家能多多帮助我 /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:33
梦幻情缘
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:769
专家分:20
注 册:2005-4-4
收藏
得分:0 
没有呀!
2005-04-06 18:55
梦幻情缘
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:769
专家分:20
注 册:2005-4-4
收藏
得分:0 
//计算一个数的正弦值、正切值、余弦值或余切值
using System;
class zhuxing
{
 public static void Main()
 {
  jisuan: Console.WriteLine("如果计算正弦值请输入1,计算余弦值请输入2,");
  Console.WriteLine("如果计算正切值请输入3,计算余切值请输入4");
  int X;//声名一个变量
  X=int.Parse(Console.ReadLine());
  switch(X)//用switch语句来做选择
  {
   case 1://求正弦值
    double a;
    Console.WriteLine("请输入你所要计算的数:");
    a=double.Parse(Console.ReadLine());
    double b=Math.Sin(a);
    Console.WriteLine("你所计算的正弦值为:"+b);
    break;
   case 2://求余弦值
    double c;
    Console.WriteLine("请输入你所要计算的数:");
    c=double.Parse(Console.ReadLine());
    double d=Math.Cos(c);
    Console.WriteLine("你所计算的余弦值为:"+d);
    break;
   case 3://求正切值
    zhengqie: Console.WriteLine("请输入你所要计算的数");
    double e;
    double w=Math.PI;
    double sum;
    int k;
    for(k=-10000;k&lt;=10000;k++)
    {
    }
    sum=k+w/2;
    e=double.Parse(Console.ReadLine());
    //k=w/2不能求正切值
    if(sum==e)
    {
     Console.WriteLine("你所输入的值不能求正切,请重新输入!");
     goto zhengqie;
    }
    double f=Math.Tan(e);
    Console.WriteLine("你所计算的正切值为:"+f);
    break;
   case 4://未找到计算余切的函数
    Console.WriteLine("非常对不起,还未找到计算余切的函数");
    break;
   default:
    Console.WriteLine("你的所输入的信息是错误的,请重新输入!");
    Console.WriteLine();
       break;
         }
  bool q = true;
  while(q)
  {
   //如果想继续查看值日的情况请输入Y或y,否则请输入N或n.
  chongxin: Console.WriteLine("你还想要计算吗?Y/N");
   string p;
   p=Console.ReadLine();
   switch(p)
   {
    case "Y":
    case "y":
     //用goto语句返回到jisuan:
     goto jisuan;
    case "N":
    case "n":
     Console.WriteLine("再见了,同志.");
     q=false;
     break;
    default:
     //判断所输入的信息错误.
     Console.WriteLine("你所输入的信息有错误!请你重新输入.");
     Console.WriteLine();
     q=true;
     //返回到chongxin;  
     goto chongxin;
   }
  }
  System.Threading.Thread.Sleep(20);
 }
}
2005-04-06 18:57
梦幻情缘
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:769
专家分:20
注 册:2005-4-4
收藏
得分:0 
可以看看!
2005-04-06 18:58
shevchenkoka
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2005-3-27
收藏
得分:0 
[原创]
你是谁啊!
可以认识一下吗?
2005-04-06 21:10
快速回复:计算几个数的和
数据加载中...
 
   



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

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