将字符串倒序
来源:互联网 发布:蜘蛛池域名收录 编辑:程序博客网 时间:2024/05/11 21:39
.继续在该类中编写一下方法,名称为Reconvert,参数一个,但可以是字符串、整数、单精度、双精度,方法功能返回参数的逆序。如Reconvert(6221982)返回值为2891226。提示:将string转换为Char char[] c=strS.ToCharArray()using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{ class MyClass{ string m; char n; public MyClass() { } public MyClass(string m1,char n1) { m=m1; n=n1; } public int CountChar() { int x = 0; char[] a = m.ToCharArray(); for (int i = 0; i < m.Length; i++) { if (a[i] == n) x++; } return x; } public void Reconvert(string x) { char[] b = x.ToCharArray(); for (int i = 0; i < x.Length; i++) { Console.WriteLine(b[x.Length - i - 1]); } } ~ MyClass() { }} class Program { static void Main(string[] args) { int s; MyClass mc = new MyClass("063353222", '2'); s= mc.CountChar(); Console.WriteLine("2出现的次数为:"+s); MyClass mc2 = new MyClass("akfbriafsaa", 'a'); s = mc2.CountChar(); Console.WriteLine( "s出现的次数为:" + s); Console.WriteLine("abcdefg的倒序:"); mc2.Reconvert("abcdefg"); Console.ReadLine(); } }}
0 0
- 将字符串倒序
- 如何将一个字符串倒序
- 将字符串abc倒序输出
- 将字符串倒序大写显示
- <C++>将字符串倒序输出
- 汇编程序:将字符串倒序输出
- 将一个字符串倒序,如“abcd”倒序后变为“dcba”
- StrReverse函数:将制定字符串倒序排列
- 将字符串中的单词进行倒序
- 遇到空格,将字符串倒序输出
- 如何将一个字符串倒序输出
- 344. Reverse String(将字符串倒序输出)
- 用指针将英文字符串倒序排列。
- 数组倒序 & 字符串倒序
- 字符串倒序
- 字符串倒序
- 字符串倒序
- 倒序字符串
- Maximal Rectangle [leetcode] 的三种思路
- 跟我一起学extjs5(31--加入模块和菜单定义[4前台通过ajax来调用数据与展示])
- First Steps to Scala
- MFC复习和学习 第五章 MFC动态创建 MFC文档 MFC消息处理 MFC单文档应用程序 MFC多文档应用程序
- 解决vc dll导出函数名字发生改变问题
- 将字符串倒序
- Apache Kafka-0.8.1.1源码编译
- 懒汉模式和饿汉模式
- 添加调试选项编译出现错误
- Fedora下载地址
- 配置 Gvim 的 .gvimrc 文件
- 化茧成蝶,程序员的必经之路
- 谈抽象1——无脑copy等于自杀
- 没有什么事情会一帆风顺