当前位置:编程学习 > C#/ASP.NET >>

求c#编程把100~200间能被7整除的数,每行输出10个,并计算共有几个这样的数

求c#编程把100~200间能被7整除的数,每行输出10个,并计算共有几个这样的数
答案:using System;
using System .Text ;
using System .Collections .Generic ;

namespace windshadow123
{
 class Program
 {
  
  public static void Main(string[] args)
  {
   int  a =0;
   int b =0;
   for(int i =100;i<=200;i++)
   {
    
    if(i%7==0)
    {    
     Console .Write("{0,5}",i);
     b=b+1;
     a=a+1;
    }
    if(a==10)
    {
     Console .WriteLine ();
     a=0;
    }
   
   }
   Console .WriteLine ();
   Console .Write("  能被7整除有:{0,3}个",b);
   Console .ReadKey ();
  }
 }
}

public void test()

{

for(int i=100;i<=200;i++)
  {
  
   if(i%7==0)
   {
   Conslo.writeline(i);
   count++;
        if(count%10==0)

      Conslo.writeline("\n");

   }
   }
   Conslo.writeline("\n%d",count);
}

#include <iostream.h>
#include <stdio.h>
void main()
{
  int count=0;
  for(int i=100;i<=200;i++)
  {
  
   if(i%7==0)
   {
   printf(" %d",i);
   count++;
        if(count%10==0)printf("\n");

   }
   }
      printf("\n%d",count);
}


main()
{
  int count=0;
  for(int i=100;i<=200;i++)
  {
  
   if(i%7==0)
   {
   printf(" %d",i);
   count++;
        if(count%10==0)printf("\n");

   }
   }
      printf("\n%d",count);
}

    class Program
    {
        static void Main(string[] args)
        {
            int count =0;
            for (int i = 100; i <= 200; i++)
            {
               
                    if (i % 7 != 0)
                    {
                        continue;
                        
                    }
                    count++;

                    Console.Write(i + "\t");
                    if (count % 10 ==0)
                    {
                       
                        Console.Write("\n");
                    }
                  
               
            }
            Console.WriteLine("总有{0}个数!", count);
        }
    }

上一个:编程c#语言中,下面关键字的意思都是什么?
下一个:急!!求一个用C#套接字编程做的简单的聊天系统

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,