static int LinesCount(string str)
来源:互联网 发布:剑网三脸型数据 编辑:程序博客网 时间:2024/04/27 20:32
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static int LinesCount(string str)
{
int i = 0;
int counter=0;
for (i = 0; i < str.Length; i++)
{
if (str[i] == '\n')
{
++counter;
}
}
return counter;
}
static List<int> PositionList(string str,string[] args)//public private
{
List<int> result = new List<int>();
foreach (string arg in args)
{
int posStart=0;
int index = 0;
while ((index = str.IndexOf(arg, posStart)) != -1)
{
result.Add(index);
posStart = index + 1;
if (posStart >= str.Length - 1)
{
break;
}
}
}
//sort asc
result.Sort();
return result;
}
static string GetLine(string str,int pos)
{
int posA = pos;
int posB = pos;
while (str[posA]!='\n')
{
posA -= 1;
if (posA == 0)
break;
}
posA = (str[posA] == '\n') ? (posA + 1) : posA;
while (str[posB] != '\n')
{
posB += 1;
if (posB == str.Length)
{
break;
}
}
posB = (str[posB] == '\n') ? posB : (posB - 1);
return str.Substring(posA, posB - posA);
}
static void Main(string[] args)
{
}
}
}
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static int LinesCount(string str)
{
int i = 0;
int counter=0;
for (i = 0; i < str.Length; i++)
{
if (str[i] == '\n')
{
++counter;
}
}
return counter;
}
static List<int> PositionList(string str,string[] args)//public private
{
List<int> result = new List<int>();
foreach (string arg in args)
{
int posStart=0;
int index = 0;
while ((index = str.IndexOf(arg, posStart)) != -1)
{
result.Add(index);
posStart = index + 1;
if (posStart >= str.Length - 1)
{
break;
}
}
}
//sort asc
result.Sort();
return result;
}
static string GetLine(string str,int pos)
{
int posA = pos;
int posB = pos;
while (str[posA]!='\n')
{
posA -= 1;
if (posA == 0)
break;
}
posA = (str[posA] == '\n') ? (posA + 1) : posA;
while (str[posB] != '\n')
{
posB += 1;
if (posB == str.Length)
{
break;
}
}
posB = (str[posB] == '\n') ? posB : (posB - 1);
return str.Substring(posA, posB - posA);
}
static void Main(string[] args)
{
}
}
}
0 0
- static int LinesCount(string str)
- 005 str.charAt(int) str.indexOf(String)
- public int indexOf(String str)(Java)
- static std::string jstring2string (jstring str)
- Graphics.drawString(String str,int x,int y)注意事项
- leetcode 412 to_string 转string atoi(str.c_str())转int
- 对 static const char* const str[] = {“string”} 的理解
- 详解public static int parseInt(String s, int radix)
- str[] , *str , static str[]的区别
- 写一个方法 String left(String str ,int n) str字符串中可能包含中文,中文是2bytes
- str to int 转换
- str-int函数
- str convert to int
- String str; str=str.substring()
- reverse(string str,int n) 交换指定字符串中的子字符串
- int -> String String -> int
- 通过String找出所有数据及组合的和 findSum(int sum, String str) str like"35,20,15,10,5"
- str string 内存泄露
- 汉诺塔
- 全局获取Context的技巧
- 设计模式之单例模式
- 命令模式
- 推荐系统的应用案例剖析
- static int LinesCount(string str)
- java:Format
- 【UFLDL-exercise8 Linear Decoder】
- LBS应用的路径引导方法
- longest consecutive sequence
- 《第一行代码》第六章 SQLite存储Test
- Linux 内核堆栈
- C++ —— 宏对于简化类接口的奇技淫巧
- c++作业3