- Console.WriteLine("请输入:");
- string strInput=Console.ReadLine();
- string[] strNums = strInput.Split(new char[]{' '},StringSplitOptions.RemoveEmptyEntries);
- string jishu = null, oushu = null;
- int[] intNums = new int[strNums.Length];
- int i = 0;
- try
- {
- //转换
- foreach (string s in strNums)
- {
- intNums[i] = Convert.ToInt32(s);
- i++;
- }
- //判定并拼接成字符串
- for (int j = 0; j <intNums.Length; j++)
- {
- if (intNums[j] % 2 == 0)
- {
- oushu = oushu + intNums[j].ToString() + " ";
- }
- else
- {
- jishu = jishu + intNums[j].ToString() + " ";
- }
- }
- Console.WriteLine("{0} {1}",jishu,oushu);
- }
- catch(Exception)
- {
- Console.WriteLine("你输入的不是数字!");
- }
- Console.ReadKey();
复制代码 好吧我是来骗技术分的{:soso_e149:} |