马上加入IBC程序猿 各种源码随意下,各种教程随便看! 注册 每日签到 加入编程讨论群

C#教程 ASP.NET教程 C#视频教程程序源码享受不尽 C#技术求助 ASP.NET技术求助

【源码下载】 社群合作 申请版主 程序开发 【远程协助】 每天乐一乐 每日签到 【承接外包项目】 面试-葵花宝典下载

官方一群:

官方二群:

大神们求救 键盘输入数字求出平均值

  [复制链接]
查看12122 | 回复10 | 2014-11-10 17:23:21 | 显示全部楼层 |阅读模式
大神们  救命啊
ibcadmin | 2014-11-11 11:23:20 | 显示全部楼层
什么意思
C#论坛 www.ibcibc.com IBC编程社区
C#
C#论坛
IBC编程社区
Espier | 2014-11-11 17:24:54 | 显示全部楼层
本帖最后由 Espier 于 2014-11-12 06:49 编辑

main()
{  float a,b;
        int c,d;
  a:printf("零+回车求和\n请输入数字:\n");
         scanf("%f", &a);
        b= a + b;
        if (a == 0)
                goto b;
        else                d+=1;
                goto a;
  b:printf("平均数为:\n%.3f", b / d);
        printf("\n输入1继续");
        scanf("%d", &c);
        if (c == 1)
                goto a;
        else
                printf("点击关闭");
}
ibcadmin | 2014-11-12 09:14:40 | 显示全部楼层
你这是撒语言, 这是c#论坛
b/d 就是平均值了啊

点评

2楼用的是C,不过程序看起来好乱的样子  详情 回复 发表于 2014-11-12 10:05
C#论坛 www.ibcibc.com IBC编程社区
C#
C#论坛
IBC编程社区
沐府小悠然 | 2014-11-12 10:05:20 | 显示全部楼层
ibcadmin 发表于 2014-11-12 09:14
你这是撒语言, 这是c#论坛
b/d 就是平均值了啊

2楼用的是C,不过程序看起来好乱的样子
沐府小悠然 | 2014-11-12 10:30:25 | 显示全部楼层
[C#] 纯文本查看 复制代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace average
{
    class Program
    {
        static void Main(string[] args)
        {
            int source, count, sum;
            count = 0;
            sum = 0;
            Console.WriteLine("输入数字(stop退出):");
            while (true)
            {
                try
                {
                    string str = Console.ReadLine();
                    if (str.Equals("stop"))
                    {
                        break;
                    }
                    else
                    {
                        source = int.Parse(str);
                        sum += source;
                        count += 1;
                    }
                }
                catch (Exception ex)
                {

                }
            }

            Console.WriteLine("avg = {0}",sum / count);
            Console.ReadLine();
        }
    }
}
ibcadmin | 2014-11-12 13:51:34 | 显示全部楼层
沐府小悠然 发表于 2014-11-12 02:05
2楼用的是C,不过程序看起来好乱的样子

- -我停留在C#了...
C#论坛 www.ibcibc.com IBC编程社区
C#
C#论坛
IBC编程社区
ibcadmin | 2014-11-12 13:52:23 | 显示全部楼层
沐府小悠然 发表于 2014-11-12 02:30
[mw_shl_code=csharp,true]using System;
using System.Collections.Generic;
using System.Linq;

生日快乐

点评

谢谢  详情 回复 发表于 2014-11-13 09:11
C#论坛 www.ibcibc.com IBC编程社区
C#
C#论坛
IBC编程社区
沐府小悠然 | 2014-11-13 09:11:28 | 显示全部楼层
lolita | 2014-12-13 17:14:11 | 显示全部楼层
二楼看的我好迷茫。。
*滑块验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则