用c#写出的,帮忙一下

qq_45808024 2020-01-06 01:59:54
求出10000以内千位数上的数减百位数减十位数上的数减个位数上的数大于零的个数cnt,再求出所有满足此条件的四位数平均值pjz1,以及不满足此条件的四位数平均值pjz2,最后调用函数把结果输出。
...全文
90 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_45808024 2020-01-06
  • 打赏
  • 举报
回复
已经写出来了,谢谢了
  • 打赏
  • 举报
回复
引用 6 楼 qq_45808024 的回复:
是在书上的课后题
你拿去修修改改应该能用了
qq_45808024 2020-01-06
  • 打赏
  • 举报
回复
引用 5 楼 年轻的程序员小唐的回复:

       static int a;
       static int b;
       static int c;
       static int d;
       static List<int> counts1 = new List<int>();
       static List<int> counts2 = new List<int>();
       static double pjz1;
       static double pjz2;
        static void Main(string[] args)
        {
            for (int i = 1000; i < 10000; i++)
            {
                  a = i / 1000;
                b = i % 1000 / 100;
                c = i % 100 / 10;
                d = i % 10;
                if (a - b - c - d > 0)
                { counts1.Add(i); }
                else
                { counts2.Add(i); }
            }
            pjz1 = counts1.Average();
           pjz2 = counts2.Average();
            Console.WriteLine(pjz1+","+pjz2);
        }
    }
       
期末复习题?
是在书上的课后题😂
  • 打赏
  • 举报
回复

       static int a;
       static int b;
       static int c;
       static int d;
       static List<int> counts1 = new List<int>();
       static List<int> counts2 = new List<int>();
       static double pjz1;
       static double pjz2;
        static void Main(string[] args)
        {
            for (int i = 1000; i < 10000; i++)
            {
                  a = i / 1000;
                b = i % 1000 / 100;
                c = i % 100 / 10;
                d = i % 10;
                if (a - b - c - d > 0)
                { counts1.Add(i); }
                else
                { counts2.Add(i); }
            }
            pjz1 = counts1.Average();
           pjz2 = counts2.Average();
            Console.WriteLine(pjz1+","+pjz2);
        }
    }
       
期末复习题?
Jiang_Mr 2020-01-06
  • 打赏
  • 举报
回复
引用 3 楼 HerryDong 的回复:
就是让你们免费帮他做作业~
写作业,石锤了
HerryDong 2020-01-06
  • 打赏
  • 举报
回复
就是让你们免费帮他做作业~
Bridge_go 2020-01-06
  • 打赏
  • 举报
回复

int a = num / 1000;  //千位
int b = num / 100 % 10;  //百位
int c = num / 10 % 100 % 10;  //十位
int d = num % 1000 % 100 % 10;  //个位
雨何方 2020-01-06
  • 打赏
  • 举报
回复
用substring就可以了实现了。

111,056

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧