usingSystem;
usingSystem.Collections.Generic;
usingSystem.Text;
namespaceConsoleApplication1
{
classProgram
{
staticvoidMain(string[]args)
{
stringstrtemp=Console.ReadLine();
Console.WriteLine("奇数和:{0}",jisuanjishuhe(strtemp));
Console.WriteLine("偶数和:{0}",jisuanoushuhe(strtemp));
Console.WriteLine("按回车退出");
Console.ReadLine();
}
staticintjisuanjishuhe(stringstr)
{
inttemp=0;
foreach(charcinstr)
{
inti=(Convert.ToInt32(c)-48);
if(i%2!=0)
{
temp+=i;
}
}
returntemp;
}
staticintjisuanoushuhe(stringstr)
{
inttemp=0;
foreach(charcinstr)
{
inti=(Convert.ToInt32(c)-48);
if(i%2==0)
{
temp+=i;
}
}
returntemp;
}
}
}
------------------
写代码辛苦,采纳吧