正数之和

来源:互联网 发布:linux 部署gitlab 编辑:程序博客网 时间:2024/04/30 15:48
  1. //        
  2. // Copyright (c) 2014软件技术1班        
  3. // All rights reserved.         
  4. // 作    者:A08梁运基         
  5. // 完成日期:2014年 11 月 23 日         
  6. // 版 本 号:v1.0         
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {            
            int a, b;//定义变量a,b;
            Console.WriteLine("请输入一个值");
            a = Convert.ToInt32(Console.ReadLine());//赋值给a;          
            if (a < 0) 
            b = -1 * a; 
            if (a>0)
            b=a ;
            Console.WriteLine("{0}",a  );//输出;
            Console.Read();
        }

    }

                                                                                     运行结果如下

}
0 0
原创粉丝点击