1, 2, 13, 14, 105, 106, 1007, 1008, 2, 13, 14, 105, 106, 1007, 1008, 13, 14, 105, 106, 1007, 1008, 14, 105, 106, 1007, 1008, 105, 106, 1007, 1008, 106, 1007, 1008, 1007, 1008, 1008, 1 2 13 14 105 106 1007 1008 |
| " 1, 2, 13, 14, 105, 106, 1007, 1008, " |
前田稔(Maeda Minoru)の超初心者のプログラム入門
![]()
![]()
/********************************************/
/*★ 数字の文字列を配列に変換 前田 稔 ★*/
/********************************************/
using System;
class Prog
{
static string str = " 1, 2, 13, 14, 105, 106, 1007, 1008, ";
static int[] t = new int[8];
public static void Main()
{
int pt, i;
string wk;
wk = str;
for(i=0; i<8; i++)
{
Console.WriteLine("{0}", wk);
pt = wk.IndexOf(',');
t[i] = Convert.ToInt32(wk.Substring(0,pt));
wk = wk.Substring(pt+1);
}
for(i=0; i<8; i++)
Console.WriteLine("{0}", t[i]);
}
}
|
|
static string str = " 1, 2, 13, 14, 105, 106, 1007, 1008, "; static int[] t = new int[8]; |
int pt, i;
string wk;
wk = str;
for(i=0; i<8; i++)
{
pt = wk.IndexOf(',');
t[i] = Convert.ToInt32(wk.Substring(0,pt));
wk = wk.Substring(pt+1);
}
|
string A = "abcdecd"; // 被検索文字列
string B = "cd"; // 検索文字列
int idx = A.LastIndexOf(B); // 5(最後の見つかった位置)
|
![]()
[Next Chapter ↓]カンマで区切られた数字を float に変換
[Previous Chapter ↑]string⇔char[]