现在的位置: 首页 > 综合 > 正文

C#输入一组整数,输出所有的奇数

2013年09月02日 ⁄ 综合 ⁄ 共 304字 ⁄ 字号 评论关闭
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("请输入一串数字");

            string s = Console.ReadLine();

            char[] chnum = s.ToCharArray();//转化为字符数组

            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] % 2 != 0)
                {
                    Console.Write(s[i]);

                }
            }


          
        }
    }
}

抱歉!评论已关闭.