zoukankan      html  css  js  c++  java
  • .Net基础篇_学习笔记_第六天_for循环语法_正序输出和倒序输出

    for TAB  和 forr TAB

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 using System.Threading.Tasks;
     6 
     7 namespace 第六天_do_while循环
     8 {
     9     class Program
    10     {
    11         static void Main(string[] args)
    12         {
    13             for (int i = 100; i <= 999; i++)
    14             {
    15 
    16                 int bai = i/100;
    17                 int shi = i%100/10;
    18                 int ge = i%10;
    19                 if (bai*bai*bai+shi*shi*shi+ge*ge*ge==i)
    20                 {
    21                     Console.WriteLine("水仙花数有{0}",i);
    22                 }
    23             }
    24             Console.ReadKey();
    25         }
    26     }
    27 }
     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 using System.Threading.Tasks;
     6 
     7 namespace 第六天_do_while循环
     8 {
     9     class Program
    10     {
    11         static void Main(string[] args)
    12         {
    13             int sum = 0;
    14             int n = 100;
    15             for (int i = 1; i <=n; i+=2)
    16             {
    17                 sum += i;
    18             }
    19             Console.WriteLine(sum);
    20             Console.ReadKey();
    21         }
    22     }

    100以内所有偶数的和,所有奇数的和,所有整数的和......

  • 相关阅读:
    网页的摘要信息
    自我介绍
    DIV和SPAN的区别
    软件工程简介
    设置层的漂移
    构建之法现代软件工程
    手机验证码的相关知识
    Python2和Python3的区别
    我的第一个练习
    结对编程后传之做汉堡
  • 原文地址:https://www.cnblogs.com/NBOWeb/p/7210867.html
Copyright © 2011-2022 走看看