using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string strtemp = Console.ReadLine();
Console.WriteLine("奇数和:{0}"答亏,jisuanjishuhe(strtemp));
Console.WriteLine("偶数和:{0}", jisuanoushuhe(strtemp));
Console.WriteLine("按回车退出");
Console.ReadLine();
}
static int jisuanjishuhe(string str)
{
int temp=0;
foreach (char c in str)
{
int i=(Convert.ToInt32(c)-48);
if ( i% 2 != 0)
{
temp += i;
}
}
return temp;
}
static int jisuanoushuhe(string str)
{
int temp = 0;
foreach (char c in str)
{
int i = (Convert.ToInt32(c) - 48);
if (i % 2 == 0)
{
temp += i;
}
}
return temp;
}
}
}
------------------
写拆运代清御神码辛苦,采纳吧