各位高手帮帮忙 1、 用C#编程计算1!+2!+3!+...+10!的结果。2、 用C#编程由用户输入一个字符串,统计该字符串中数字、字母和其他字符出现的个数。3、 输入10个数,使它们从小到大排列。希望各位大侠能够把源程序发来看一下。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 第一个 int x = 10; int Result = 0; for (int count = 0; count < x; count++) { Result = Result + count; } MessageBox.Show(Result.ToString()); 第二个: public static Hashtable CharSameCount(string Str) { char[] TempArray = Str.ToCharArray(); ArrayList nStr = new ArrayList(); for (int i = 0; i < TempArray.Length; i++) { if (!nStr.Contains(TempArray[i])) { nStr.Add(TempArray[i]); } } char[] newStr = (char[])nStr.ToArray(typeof(char)); Hashtable ht = new Hashtable(); for (int count = 0; count < newStr.Length; count++) { string tempStr = Str.Replace(newStr[count].ToString(), "");//在此进行字符串字符替换为空 ht.Add(newStr[count], Str.Length - tempStr.Length);//原长度减替换后的长度 Str = tempStr; } return ht;//返回字符串中每个字符个数的哈希表。 }方法调用: string x = "bacea"; foreach (DictionaryEntry a in CharSameCount(x)) { MessageBox.Show("字符:"+a.Key.ToString()+" 数量:"+a.Value.ToString()); } 第三个: int[] x = { 10,15,30,26,24,87,59,65,4,56,21 }; Array.Sort(x);//升序(从小到大) Array.Reverse(x);//降序(从大到小) int x = 10;int Result = 0;for (int i= 0; i< x; i++) { result = result * i; }private string GetResult(string str){ int len=str.Length; str=Regex.Replace(str,"[a-zA-Z]",""); string result=(len-str.Length)+"个字母 "; len=str.Length; str=Regex.Replace(str,"[0-9]",""); result+=(len-str.Length)+"个数字 ";return result;}List<int> lst=new List<int>();for(int i=0;i<=10;i++){ lst.Add(i);}lst.Sort(); 在实际开发中数据库的时间字段是设成datetime好还是String好呢? SendKeys.类的Send()方法 是不是一定要放到单击事件中 很诡异啊,高手帮帮忙。access数据库update更新不成功 关于WEB页面设计 帮看一段验证用户登录的SQL存储过程 C#中如何判断目录权限是可写的,还有删除的时候,如何判断文件正在使用? 100求大虾帮忙!combox绑定报错问题! 求一段能高强度过滤html代码的函数 怎样在dataset中获得一个DataGridTextBox的位置信息!急! 菜单上添加图片 或小图标 研究qq Farm的成果 发送AT命令到串口怎么写?
int Result = 0;
for (int count = 0; count < x; count++)
{
Result = Result + count;
}
MessageBox.Show(Result.ToString());
{
char[] TempArray = Str.ToCharArray();
ArrayList nStr = new ArrayList();
for (int i = 0; i < TempArray.Length; i++)
{
if (!nStr.Contains(TempArray[i]))
{
nStr.Add(TempArray[i]);
}
}
char[] newStr = (char[])nStr.ToArray(typeof(char)); Hashtable ht = new Hashtable();
for (int count = 0; count < newStr.Length; count++)
{
string tempStr = Str.Replace(newStr[count].ToString(), "");//在此进行字符串字符替换为空
ht.Add(newStr[count], Str.Length - tempStr.Length);//原长度减替换后的长度
Str = tempStr;
}
return ht;//返回字符串中每个字符个数的哈希表。
}方法调用: string x = "bacea";
foreach (DictionaryEntry a in CharSameCount(x))
{
MessageBox.Show("字符:"+a.Key.ToString()+" 数量:"+a.Value.ToString());
}
Array.Sort(x);//升序(从小到大)
Array.Reverse(x);//降序(从大到小)
int Result = 0;
for (int i= 0; i< x; i++)
{
result = result * i;
}private string GetResult(string str)
{
int len=str.Length;
str=Regex.Replace(str,"[a-zA-Z]","");
string result=(len-str.Length)+"个字母 ";
len=str.Length;
str=Regex.Replace(str,"[0-9]","");
result+=(len-str.Length)+"个数字 ";
return result;
}List<int> lst=new List<int>();
for(int i=0;i<=10;i++)
{
lst.Add(i);
}
lst.Sort();