TKYM's profile※ 画面は開発中のものですPhotosBlogListsMore ![]() | Help |
※ 画面は開発中のものですいろいろと作ってます。 プログラミング( VC++, C#, Javascript, PHP ) 時々ノイズ(鉄道 庭のビワ 他) |
|||||||||||||||
Public folders
|
June 23 if(0<i<100) という書き方 (C#)もちろん、 if(0<i<100) なんていう書き方は不可能である。 1: struct keisan 2: {3: public int i; 4: 5: List<range> condition; 6: 7: //tostring 8: public override string ToString() 9: {10: return "" + i; 11: } 12: 13: //コンストラクタ 14: public keisan(int i) { 15: this.i = i; 16: condition = new List<range>(); 17: } 18: 19: //新しく追加するとき 20: public keisan(keisan ks) { 21: this.i = ks.i; 22: condition = new List<range>(); 23: 24: foreach(range r in ks.condition){ 25: condition.Add(r); 26: } 27: } 28: 29: //bool へのキャスト 30: public static implicit operator bool(keisan ks){ 31: foreach(range r in ks.condition){ 32: if(r.min > ks.i || r.max < ks.i){ 33: return false; 34: } 35: }36: return true; 37: } 38: 39: //int へのキャスト 40: public static implicit operator int(keisan ks) { 41: return ks.i; 42: } 43: 44: //int からのキャスト 45: public static implicit operator keisan(int i) 46: {47: return new keisan(i); 48: } 49: 50: //オペレーター 51: 52: 53: //< 54: public static keisan low(int i, keisan ks) { 55: keisan result = new keisan(ks); 56: result.condition.Add(new range(i, int.MaxValue)); 57: 58: return result; 59: }60: public static keisan high(int i, keisan ks) 61: {62: keisan result = new keisan(ks); 63: result.condition.Add(new range(int.MinValue, i)); 64: 65: return result; 66: } 67: 68: public static keisan operator <(keisan ks, int i) { 69: return high(i, ks); 70: }71: public static keisan operator <(int i, keisan ks){ 72: return low(i, ks); 73: } 74: 75: //> 76: public static keisan operator >(int i, keisan ks){ 77: return high(i, ks); 78: }79: public static keisan operator >(keisan ks, int i){ 80: return low(i, ks); 81: } 82: 83: //<= 84: //>= 85: } 86: 87: struct range{ 88: public range(int min, int max) { 89: this.min = min; 90: this.max = max; 91: } 92: 93: public int min; 94: public int max; 95: }int 型の値と、条件を保持する構造体を作ってみて、
細かいことは考えていないが、 1: keisan k = 100; 2: 3: if (200 > k > 0) { 4: MessageBox.Show(""+k); 5: }
と、書くことができた。 February 17 Destroy で 完全消去 Destroy というソフトがある。 安全にディスク消去できるソフトらしい。 このソフトを使ってディスクを消去したいのだが、 USB まで認識させるためには、ドライバを組み込まねばならない。 そして、 FDD がないので余計ややこしい。 自分の通った道をメモしておく。 もっと簡単な方法はきっとある。
あまりこういう面倒なことはしたくない。 January 17 数式をWebに貼る方法January 02 曲線同士の交点を求めたベジエ曲線同士の交点を、(自分的にはついに)求められた。 December 07 ベジエ曲線の分割曲線を t : 1-t に分割したければ、 制御点 1-2, 2-3, 3-4 を t : 1-t に分割し、 static public PointF[,] BezierCut(PointF[] points, float t){ PointF[,] result = new PointF[2, points.Length]; //stでくぎられる点を見つける //分割前の P0, Pn が分割後の L0, Rn になる result[0,0] = points[0]; result[1,points.Length-1] = points[points.Length - 1]; PointF[] prev = points; for (int i = 1; i < points.Length; i++) { PointF[] tmp = new PointF[points.Length - i]; for (int j = 0; j < points.Length - i; j++) { //tmp[j] - tmp[j+1] の間を st で区切る tmp[j].X = prev[j].X + (prev[j + 1].X - prev[j].X) * t; tmp[j].Y = prev[j].Y + (prev[j + 1].Y - prev[j].Y) * t; } result[0,i].X = tmp[0].X; result[0,i].Y = tmp[0].Y; result[1,points.Length - i - 1].X = tmp[tmp.Length - 1].X; result[1,points.Length - i - 1].Y = tmp[tmp.Length - 1].Y; prev = tmp; //算出したものを保持 } return result; } このシリーズの他記事 http://prog-city.spaces.live.com/lists/cns!E5379F11D9E8BB3F!1047/
|
|
|||||||||||||
|
|