「void」を含む日記 RSS

はてなキーワード: voidとは

2012-02-08

[][]JK N Q UV

J

jeopardize

judicious

juggle

juncture

jurisdiction

juvenile

K

kick up a fuss

knack


N

negate

negligible

neural

niche

nod off   (in a meeting

nonchalant

novice

Q

quadruple

qualified

quandary

quarantine

quell

quorum

quota


U

ultimatum

uncouth

uncover

undergo

undermine

undertake

unearth

unravel

unscathed

upgrade

upheaval

uphold



V

valiant

variant

【名】

異なるもの、変形、異形、変異形、変異株、変異体、変化

機械》改良型


vandalism

vehement (desire

vent

venue

verdict

verify

veto

viability

vibrant

vie for

vindicate

void

volatile

vouch for

2011-12-26

http://anond.hatelabo.jp/20111225211334

畑の違いを感じるなぁ。

デジタルネイティブ族にとって、少年ジャンプ深夜ラジオ映画というアナログメディア青春を過ごした世代が、はてなみたいな(かつての)テジタル族の根城で「カルチャーシーン」を語っているというのが、新鮮。

アナログメディア世代にとって、深夜ラジオの「伊集院光」って特別なサブカルチャー存在なんだなぁ。。

あたしゃ、その頃はfjvoid先生やmohta先生書き込みを読んでたよ。

2011-12-17

CStaticコントロールにCBitmapを表示する方法

//ダイアログクラスにメンバ変数定義
std::auto_ptr<CBitmap> m_pbmp;

//bitmapを設定するメンバ関数
void C*****Dlg::Set*****Bitmap() {
	CDC* pDC = GetDC();
	CDC memdc;
	memdc.CreateCompatibleDC(pDC);
	m_pbmp.reset(new CBitmap());
	CBitmap& bmp = *m_pbmp;
	bmp.CreateCompatibleBitmap(pDC, width, height);
	
	CBitmap* old = memdc.SelectObject(&bmp);
	memdc.FillSolidRect(0,0,width,height, color);
	memdc.SelectObject(old);
	((CStatic*)GetDlgItem(IDC_STAIC_*********))->SetBitmap(bmp);
}

スクリーンと同じデバイスコンテキストビットマップ作成し単色で描画している。描画し終わった後のSelectObjectを忘れてはいけない。

CStatic::SetBitmapに渡した後も実際に描画されるまでCBitmapの寿命保証しなければならない。

そのためメンバ変数にCBitmapを持たせるがCBitmapが再利用を考慮していないという驚くべき仕様なので仕方なくauto_ptrでラップしている。

いい加減MFC滅びてくれないかな。抽象度が低すぎる。こんな記事自分ブログに書きたくないよ。

さらにVisualStudio 2005のauto_ptrのバグを見つけた operator = にポインタを渡すとおかしくなる。これは本来コンパイルエラーになるべきで代わりにresetメンバ関数を使用するべきだ。

修正するには<memory>ヘッダのauto_ptr_refのコンストラクタひとつ上の行(642行目)に private: template<class T> friend class auto_ptr; を挿入する。

これならばアクセス制御をしているだけなので他のコードへの影響は無いと思う。

2011-11-20

void function(){

 return 0;

}

2011-09-08

Feeling of the cat

Translated from http://anond.hatelabo.jp/20110907020451




For a long time, I am in a dark box.




According to someone's comment I heard outside of the box, a tiny bottle containing deadly poison is located in this box. Although the bottle is completely sealed, a hammer is positioned in the vicinity of the bottle. And they said the hammer would fall down at a certain time.




When is "the certain time"? I don't know. In this very moment? Or distant future? Possibly, it already has come (I don't want to think about it). No one can affect the hammer. As an independent event, it will fall down with probability 50%. The probability is exactly 50%. Possibly, the bottle may be broken, or may not. About myself, dead, or, alive.




I must say, how terrible the situation is.




It is impossible for me to avoid having a furious indignation. My life, the most important issue for me, is completely away from me, and is solely dependent on the simple figure, FIFTY PERCENT! Too much terrible.




Additionally, and I think it is completely unreasonable, I am shackled in many ways to keep the probability at exactly 50%.




Visual perception. The box is completely shielded from any light. It's for avoiding me from finding and destroying the bottle and apparatus. Complete darkness. I am in the total darkness. Thus, now I can’t see even the outline of myself. Possibly it sounds strange, the darkness makes me have a doubt about the existence of my body itself.




Acoustic perception. Maybe, from the reason I mentioned above, a perfect sound insulation is used. I can’t hear even the voice of my own. I don't know the mechanism. In the first place, as I can’t see anything, how can I investigate it? So, this is only a speculation, possibly, my drum membranes were damaged before enclosure in this box, or, some special material is used for the wall of the box.




Anyway, in a dark box too much good at shielding light and sound, my visual and acoustic perception is dead just as the term indicates.




As if further confirmation are needed, a huge fatigue weighing heavily upon me is another shackle for me. It seems that they gave me some kind of muscle relaxant to avoid me from struggling. As I can’t change from the same posture, my tactile perception is almost paralyzed.




No light. No sound. Smell and taste are unreliable. Tactile perception is in malfunction. I am like a puppet. All the five senses are out of control of mine. Too much cruel. Perfect shackles. I wish if they had given a sleeping medicine. I feel I am in agony without any external injury. My life, my existence itself, is completely ignored. Such a humiliation keeps my sanity. Only such a humiliation can.




The right to control the life and death of myself is completely deprived. I hate such situation. The core determinant of the continuity of my life is completely dependent upon, solely upon, a pure probability. Completely away from anyone's will. I hate it, again, I hate it!




Why do I have to be enclosed in such a box? In such a ridiculous box, why do I have to be in fear of life and death with such perfect shackles?




Unreasonable. Cruel.




I am lonely. Am I feeling empty and flat? Difficult to avoid sobbing? No. My loneliness is much deeper. I am in a sea of void. I am alone. Completely alone. As an orphan, I was thrown into this endless darkness. I am quivering in the absolute zero.




There is no perspective in this box. Only the darkness is here. I can’t feel the bottle and the hammer. I can’t feel the wall, the bottom, and the ceiling neither. They should be there. But all the five senses of mine are deprived. I feel like there is nothing. While those things have some meanings.




Speaking honestly, I am not so sure I am in a box. I am sure that what I am exists. I am thinking. I am fantasizing. It is the evidence showing the uniqueness of mine, which is called the ego or the consciousness or the mind, is solid. But, is the uniqueness is truly enclosed in the box? Is it possible that it is floating in another space? I can’t eliminate such doubts.




Possibly, what I am here is floating in the end of the universe, or is lying down at the bottom of the Mariana Trench. Or going down from a vent of the Kilauea volcano, maybe.




I don't have any method to know how the box (enclosing me) is. All the senses of mine are dead. It is impossible for me to determine whether here is inside of a box or not.




In addition to that, I am not so sure that I am truly alive. I don't have any way to confirm such a simple thing. Possibly, the 50% probability has already passed beyond me. Maybe I am already dead. I am still alive, maybe. Injected with muscle relaxant, shallow breathes, weak heartbeats. Or, cessation of all of them, simply leaving meat bolus.




I am deprived of any capability of controlling my own body. Who can say that my mind resides in the body continuing vital activities? The five senses have been poisoned with the total darkness. They can’t function as sensory organs. I don't have any chance to know the truth. Possibly, any supposition is fabricated by myself. The situation surrounding me and the uniqueness of myself are components of programmed role-play, possibly.




About the existence of mine, I can’t determine the behavior. I hate to admit it, but I am in the middle of fluctuation.




I wish someone could find me. I wish someone could open the box and observe how I am, and determine what I am. There is not enough power inside me to do so. All I can do is to continue to quiver in the loneliness.




If I were the Almighty, I could say "Let there be light". I know it is impossible. But I can‘t help feeling how nice it would be if I could say so.




My own free will! It could fix every fluctuation surrounding myself!




At the same time, longing produces shadow. If the box is opened, I will be found and observed. As a result, what I am will be determined. To tell the truth, I can’t look away from the fact I am anxious about being determined.




Although I am unable to determine whether I am alive or dead by myself, I am afraid of the death. I am afraid that I am determined as a dead. I can’t accept. Still I can’t feel, I can’t imagine the death as a specific phenomenon. Probably, that is why I am afraid of death.




No, it should not be restricted to me. King of virtue. Deadly murderer. Regular folks. All the same. Maybe, the elder people or patients of bad disease could have some imagination sufficiently close to the true death. But, even so, it is impossible to know the specific experience of death.




In the end, death is the final destination with overwhelming significance. The time and the consciousness have an absolute irreversibility. Death also has the absoluteness which can’t be changed. Even if it is a ritual pass point or an outstanding impressive event.




Myself, the mind of mine here is, will be vanished at the moment at which how I am is determined. If they deprive the lukewarm water, in which I can’t feel the temperature, it is impossible for me to avoid exposing myself to the air.




I am afraid of such an irreversible change. It is not limited to the determination of death. Also I am so anxious that I am determined being alive.




The current existence of myself is like a tiny, tiny illusion standing on an endless point. Not larger than that. Not smaller than that. Not longer than that. Not shorter than that. No expansion. No shrinkage. Standing upon a unique single point. It is mathematically correct. I am something like a ghost staying upon such a point, having confusion about identity of myself.




The point exists at every position on a plane of coordinates, at the same time, not existing at a certain position. If a certain event occurs, on that moment, it will converge me to a single point among all the space-times, in which the event has occurred, as if having me step off a bus. Without any concern. Even if the point and I have been a one. The illusion, which has stayed in such a point, has possibilities of being real and being vanished like a mist, to an equal degree.




Now, I am existing in every time-space, I have every nature. At the same time, I am suffering from the loneliness that I am away from every nature. I wish someone can find me. At the same time, I am so anxious that where I will be, and that how I will be at that moment.




I have been released from the law of cause and effect. I am undetermined ever, for ever.

2011-05-30

http://anond.hatelabo.jp/20110530004826

Javaだけど。

class HelloWorld {
  public static void main(String args[])
  {
    System.out.println("Hellp World");
  }
}

typoバグの一種:p

2011-03-30

http://anond.hatelabo.jp/20110330125201

というわけでサンプルコード書きなおしてみた。

サンプルコード意味はないので注意な。

JAVA

public class Main {

    public static void main(String[] args) {
        int count= args.length==0?100000:Integer.parseInt(args[0]);

        long start=System.currentTimeMillis();
        Main m=new Main();

        double result=0;
        for(int i=0;i<count;i++){
            result+=m.test((double)(0.1f*i));
        }
        System.out.println(result);
        System.out.println(String.format("COMPLETE! %d msec",System.currentTimeMillis()-start));
    }

    private double product=0;
    public double test(double rad){

        return this.product+=Math.tan(rad);
    }
}

PHP

<?php
class Test{
    private $product;
    public function test($rad)
    {
        return $this->product+=tan($rad);
        
    }
}

$count =is_null($argv[1])?100000:(int)$argv[1];
$start=microtime(true);

$t=new Test();
$result=0;
for($i=0;$i<$count;$i++){
    $result+=$t->test(0.1*$i);
}
echo "{$result}\n";
printf("COMPLETE! %f msec",  (microtime(true)-$start)*1000);

結果

JAVA

$java -jar test.jar 100000
-7.524990063072938E9
COMPLETE! 31 msec

PHP

$ php -f test.php 100000
-11900078829.3
COMPLETE! 209.314108 msec

うむ。有意な差はあるっぽいな。(結果が違い過ぎてるのはなんか問題があるかもしれん)

多分、変数の型が出鱈目で計算されるようなもんだとPHPは遅くなるのだと思われ。javaは強い型制約があるから、同じ型同士の計算だと速いとか?

http://anond.hatelabo.jp/20110330114912

サンプルコード

JAVA

package test;

public class Main {

    public static void main(String[] args) {
        int count= args[0]==null?10000:Integer.parseInt(args[0]);

        long start=System.currentTimeMillis();
        Main m=new Main();
        for(int i=0;i<count;i++){
            System.out.println(m.test());
        }
        
        System.out.println(String.format("COMPLETE! %d msec",System.currentTimeMillis()-start));
    }


    public String test(){


        return "ぽぽぽぽーん";
    }
}

PHP

<?php
class Test{
    public function test(){

        return "ぽぽぽぽーん";
    }
}

$count =is_null($argv[1])?10000:(int)$argv[1];
$start=microtime(true);

$t=new Test();
for($i=0;$i<$count;$i++){
    echo $t->test()."\n";
}

printf("COMPLETE! %f msec",  (microtime(true)-$start)*1000);

結果

$ java -jar test.jar 10000

ぽぽぽ...

COMPLETE! 1008 msec

$ php -f test.php 10000

ぽぽぽ...

COMPLETE! 988.869190 msec

実行したのは全く同じ環境jdkは1.6でPHPは5.2。

どういうことなのか説明してもらおうか?

2011-03-03

ブログの問題を解いてみた

http://okajima.air-nifty.com/b/2011/01/2011-ffac.html

ぷよぷよを解く問題をやってみた

かかった時間はおおよそ1時間

途中でわからないところがあったのでくぐってしまった

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder[] blocks = {
                new StringBuilder("**GYRR"),
                new StringBuilder("RYYGYG"),
                new StringBuilder("GYGYRR"),
                new StringBuilder("RYGYRG"),
                new StringBuilder("YGYRYG"),
                new StringBuilder("GYRYRG"),
                new StringBuilder("YGYRYR"),
                new StringBuilder("YGYRYR"),
                new StringBuilder("YRRGRG"),
                new StringBuilder("RYGYGG"),
                new StringBuilder("GRYGYR"),
                new StringBuilder("GRYGYR"),
                new StringBuilder("GRYGYR")
            };

            bool updated = true;
            while (updated)
            {
            breaked:
                DumpBlock(blocks);
                for (int i = 0; i < blocks.Length; i++)
                {
                    for (int j = 0; j < blocks[i].Length; j++)
                    {
                        char c = blocks[i][j];
                        if (c == '*')
                            continue;
                        updated = false;
                        if (KillBlocks(blocks, i, j))
                        {
                            updated = true;
                            goto breaked;
                        }
                    }
                }
            }
            DumpBlock(blocks);
            Console.Read();
        }
        struct Point
        {
            public int x, y;
            public Point(int x, int y)
            {
                this.x = x;
                this.y = y;
            }
        }
        static bool KillBlocks(StringBuilder[] blocks, int x, int y)
        {
            bool[,] visted = new bool[blocks.Length,blocks[0].Length];

            MarkBlock(visted, blocks, x, y);

            Queue<Point> queque = new Queue<Point>();
            for (int i = x; i < blocks.Length; i++)
                for (int j = y; j < blocks[i].Length; j++)
                    if(visted[i,j] == true)
                        queque.Enqueue(new Point(j,i));

            if (queque.Count < 4)
                return false;

            while (queque.Count > 0)
            {
                Point p = queque.Dequeue();
                RemoveBlock(blocks, p.x, p.y);
            }
            return true;
        }
        static void MarkBlock(bool[,] visted, StringBuilder[] blocks, int x, int y)
        {
            if (x < 0 || y < 0 || x >= blocks.Length || y >= blocks[0].Length || visted[x, y] == true)
                return;
            char c = blocks[x][y];
            visted[x, y] = true;
            if (x + 1 < blocks.Length && blocks[x + 1][y] == c) MarkBlock(visted, blocks, x + 1, y);
            if (y + 1 < blocks[0].Length && blocks[x][y + 1] == c) MarkBlock(visted, blocks, x, y + 1);
            if (x > 0 && blocks[x - 1][y] == c) MarkBlock(visted, blocks, x - 1, y);
            if (y > 0 && blocks[x][y - 1] == c) MarkBlock(visted, blocks, x, y - 1);
        }
        static void DumpBlock(StringBuilder[] blocks)
        {
            foreach (StringBuilder s in blocks)
                Console.WriteLine(s);
            Console.WriteLine();
        }
        static void RemoveBlock(StringBuilder[] blocks,int x,int y)
        {
            int i;
            if (y == 0)
            {
                blocks[y][x] = '*';
                return;
            }
            for (i = y; i > 0; i--)
            {
                blocks[i][x] = blocks[i - 1][x];
            }
            blocks[i][x] = '*';
        }
    }
}

2011-02-10

http://anond.hatelabo.jp/20110209221517

Cの場合は使わないからだろ。関数内に関数

というか、Cの場合関数粒度を気にすることが多いからね。

再帰関数 > ループでかけ

たいな感じで、関数コールを嫌う文化からなぁ突き詰めると。

そういう事をしようと思わない。別な書き方をするとかじゃなかろうか?

 

いちおう、C++ならクラス内にクラスは書けるから似たような事はできる。

 

C/C++文化的に速度とメモリ重要視する言語からあんまりね、そう言うのは主流じゃないと思う。

class A{

private:

 int A:

public:

 void set_A(int &a){

  A=a;

 }

}

たいなことも・・・あまり、おすすめできないし・・・。論理的には美しいんだけど・・・いろいろ弊害もあると考えるのがC/C++

ましていわんや、関数内。

※一番痛いのは、設定関数が1箇所なので、動作変更がすぐできる>>大規模システムではコードカバレッジがあるので、

根元の関数の挙動を大きく変えられたら、上位のクラスの莫大なテストやり直しだから、1箇所変更で全箇所変わるのはデメリットw。上位で修正が基本。

というか、やっちゃだめwww。

たとえば、intをdoubleにとかなら、それもう別物だから、上位も変更でしょ。普通・・・。とか。

 

あと#define関数デバッガーでおえないので、なるべくC++コンパイラ通してinlineで書いてぇぇぇぇとか。色々。むしろ#defineで複雑なことしないで

2011-01-19

http://anond.hatelabo.jp/20110119010704

  1. Google Chromeを起動する
  2. Ctrl+D
  3. 編集ボタンを押して出てきたダイアログの「URL」欄に javascript:void(window.open('http://anond.hatelabo.jp/username/edit?title='+escape(location.href),'_blank')); をコピペ。ただし、「username」の部分は自分IDに書き換えること。
  4. 名前の欄はなんでもいい。増田レスとかなんとか好きなようにつけること。
  5. 保存先はブックマークバーが楽。
  6. 返信した日記ページを開いている時に、ブックマークバーにある「増田レス」を押せば、タイトル元増田URLが入った状態で、編集画面が開くはずだ。

最後になるが、ブックマークレットがなんだか分からないなら素直にどうやるの?と聞け。

2011-01-14

http://anond.hatelabo.jp/20110114231912

int main(void){

  int i;

  for(i = 1 ; i <;= 100 ; i++){

    printf("%d \0Fizz \0FizzBuzz "+("\x0A\x00\x00\x04\x00\x0D\x04\x00\x00\x04\x0D\x00\x04\x00\x00"[i%15]),i);

  }

  printf("\n");

  return 0;

}

かな?コンパイルしてないから、ミスあるかも

魔法じゃないよね。ただの、ありふれたCのプログラムだ。

これ以上FizzBuzzは短く出来ないと思われる。return 0 とか改行はぬけるっちゃぁ、抜けるけど・・・

void main(void){

  for(int i = 1 ; i <;= 100 ; i++){

    printf("%d \0Fizz \0FizzBuzz "+("\x0A\x00\x00\x04\x00\x0D\x04\x00\x00\x04\x0D\x00\x04\x00\x00"[i%15]),i);

  }

}

まぁ、限界だな・・・

void main(void) { for(int i = 1 ; i <;= 100 ; i++) printf("%d \0Fizz \0FizzBuzz "+("\x0A\x00\x00\x04\x00\x0D\x04\x00\x00\x04\x0D\x00\x04\x00\x00"[i%15]),i) ;}

うん、わけわからん

http://anond.hatelabo.jp/20110114224058

まぁ、今時は32Bitだし 100までしかFizzBuzzは回さないだろうから、動くんだろうな。

どうでもいいけど

cout 書いたなら、strstreamだろうし sprintf使うならprintfだろうなぁと

int main(void){

  int i;

  for(i = 1 ; i <= 100 ; i++){

    printf("%d \0Fizz \0FizzBuzz "+(i%5?(i%3?0:4):(i%3?14:10)),i);

  }

  printf("\n");

  return 0;

}

ちなみにFizzBuzzを短くするなら、こう。printfの""はポインタである。というのをつかって\0を文字列に入れ込み、数値の演算結果で文字列シフトする。

Buzz単体を表示したい時にはFizzBuzz+4相当で表示できる というのがさらにポイント

だが、こんなプログラム実際に書いてあったら、レビュー却下するだろうな・・・

難読化されているわりには、プログラム的に速くなるわけでもなんでもないから。

http://anond.hatelabo.jp/20110114202812

void fizzbuzz(int n)
{
  for(int i=1;i<=n;i++){
    char ich[sizeof(int)];
    sprintf(ich,"%d",i);
    std::cout << ((i%15==0)?"fizzbuzz":((i%5==0)?"buzz":((i%3==0)?"fizz":ich))) << std::endl;
  }
}

コードとかほんと苦手。

int main(int argc, char* argv[])
{
  void **dpj;
  dpj = (void**)calloc(411 + 1, sizeof(void*));
  return 1;
}

2011-01-11

人材獲得作戦・4 試験問題ほか

http://okajima.air-nifty.com/b/2010/01/post-abc6.html

迷路の最短経路を求める問題が出たので解いてみた

幅優先探索を使えばいいのがわかっていたのですんなりかけたのだが無限ループになる個所があったので動くようになるまで時間がかかった


using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace MazeFind
{
    class Point
    {
        public int x;
        public int y;
        public Point before;
        public Point(int x, int y,Point before)
        {
            this.x = x;
            this.y = y;
            this.before = before;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            const char BreakChar = 'B';
            const char GoalChar = 'G';
            const char WallChar = '*';
            const char BeforeChar = '.';

            StringBuilder[] maze = new StringBuilder[]{
                new StringBuilder("**************************"),
                new StringBuilder("*S* *                    *"),
                new StringBuilder("* * *  *  *************  *"),
                new StringBuilder("* *   *    ************  *"),
                new StringBuilder("*    *                   *"),
                new StringBuilder("************** ***********"),
                new StringBuilder("*                        *"),
                new StringBuilder("** ***********************"),
                new StringBuilder("*      *              G  *"),
                new StringBuilder("*  *      *********** *  *"),
                new StringBuilder("*    *        ******* *  *"),
                new StringBuilder("*       *                *"),
                new StringBuilder("**************************"),
            };
            Point start = new Point(1, 1,null);

            //最短経路を探索する
            Queue<Point> queque = new Queue<Point>();
            queque.Enqueue(start);

            while (queque.Count > 0)
            {
                Point now = queque.Dequeue();
                if (maze[now.y][now.x] == BreakChar)
                    Console.WriteLine("break");
                if (maze[now.y][now.x] == WallChar || maze[now.y][now.x] == BeforeChar)
                    continue;
                else if (maze[now.y][now.x] == GoalChar)
                {
                    Point p = now.before;
                    while (p != null)
                    {
                        maze[p.y][p.x] = '@';
                        p = p.before;
                    }
                    break;
                }

                if (maze[now.y - 1][now.x] != '#')
                {
                    queque.Enqueue(new Point(now.x, now.y - 1, now));
                    maze[now.y][now.x] = '.';
                }
                if (maze[now.y][now.x + 1] != '#')
                {
                    queque.Enqueue(new Point(now.x + 1, now.y, now));
                    maze[now.y][now.x] = '.';
                }
                if (maze[now.y + 1][now.x] != '#')
                {
                    queque.Enqueue(new Point(now.x, now.y + 1, now));
                    maze[now.y][now.x] = '.';
                }
                if (maze[now.y][now.x - 1] != '#')
                {
                    queque.Enqueue(new Point(now.x - 1, now.y, now));
                    maze[now.y][now.x] = '.';
                }
            }

            //結果を出力する
            foreach (StringBuilder s in maze)
                Console.WriteLine(s.ToString().Replace(BeforeChar,' '));

            Console.ReadLine();
        }
    }
}
<||

2010-11-17

[] MotionState

sizeof(MotionState) = 0xa8
+0x00	byte ?
+0x01	byte ?
+0x02	byte ?
+0x03	byte ?
+0x04	short x_offset;
+0x06	short y_offset;
+0x08	short duration;
+0x0a	short imageNumber;
+0x0c	short transform_origin_x;
+0x0e	short transform_origin_y;
+0x10	short tex_width;
+0x12	short tex_height;
+0x14	byte blend_mode;
+0x15	BAADF00D (3)
+0x18	RenderInfo* type2;
+0x1c	short damage;
+0x1e	short proration;
+0x20	short guard_damage;
+0x22	short spirit_damage;
+0x24	short untech;
+0x26	short damage_motion_percentage;
+0x28	short limit;
+0x2a	short self_hitstop_hit;
+0x2c	short enemy_hitstop_hit;
+0x2e	short self_hitstop_guard;
+0x30	short enemy_hitstop_guard;
+0x32	short cardgain_hit;
+0x34	short cardgain_guard;
+0x36	short hit_effect_air;
+0x38	short hit_effect_ground;
+0x3a	BAADF00D (2)
+0x3c	float velocity_x;
+0x40	float velocity_y;
+0x44	short sound_type;
+0x46	short effect_type;
+0x48	byte attack_level;
+0x49	byte combo_correction;
+0x4a	BAADF00D (2)
+0x4c	uint fflags;
+0x50	uint aflags;
+0x54	Rect* collision;
+0x58	BAADF00D (4)
+0x5c	Rect* hitboxes;
+0x60	Rect* hitboxes_end;
+0x64	Rect* hitboxes_end;
+0x68	BAADF00D (4)
+0x6c	Rect* attackboxes;
+0x70	Rect* attackboxes_end;
+0x74	Rect* attackboxes_end;
+0x78	BAADF00D (4)
+0x7c	void* ?
+0x80	void* ?
+0x84	void* ?	
+0x88	short ?
+0x8a	short ?
+0x8c	byte ?
+0x8d	byte ?
+0x8e	byte ?
+0x8f	byte ?
+0x90	void* ?
+0x94	void* ?
+0x98	short ?
+0x9a	short ?
+0x9c	byte ?
+0x9d	byte ?
+0x9e	byte ?
+0x9f	byte ?
+0xa0	short ?
+0xa2	short ?
+0xa4	short ?
+0xa6	BAADF00D (2)

2010-10-18

オレが昔作ったプログラムが改変されて出回ってた。

VBで書いてたんだけど、ソースコード見てみたら、Sub が Function に直されてる。

何か返してるのかと思ったら何も返してない。

なんじゃこりゃ。



C言語プログラマーなのか?Void なのか?

意味わかんねぇ直しすんじゃねぇ。

2010-08-16

if も 3項演算子も for も do whileすらもない ifなしの Fizz Buzz

だから、プログラム記法がなくても<>が無いから化けないぜ

#include "stdio.h"
#include "stdlib.h"

int cnumber=0;

void fizz(){
    printf("fizz");
    cnumber++;
};

void nonfizz(){
};

void buzz(){
    printf("buzz");
    cnumber++;
};

void nonbuzz(){
};

void number(int i){
    printf("%d",i);
    cnumber = 0;
}

void nonnumber(int i){
    cnumber = 0;
}

void myexit(void){
    printf("\n Hit return key to exit\n");
    getchar();
    exit(1);
}

void noexit(void){
}

void (*pfizz[3])() = {fizz,nonfizz,nonfizz};
void (*pbuzz[5])() = {buzz,nonbuzz,nonbuzz,nonbuzz,nonbuzz};
void (*pnumber[3])(int) = {number,nonnumber,nonnumber};
void (*pmyexit[2])() = {noexit,myexit};

int main(int argc, char* argv[])
{
    int loopmax = (111+222+333)*10;
    int i = 1;
    head:
    (*pfizz[i%3])();
    (*pbuzz[i%5])();
    (*pnumber[cnumber])(i);
    (*pmyexit[!(loopmax-i)])();
    printf(",");
    i++;
    goto head;
    return 0;
}

includeが<>を使ってないので必要ならパスは各自で通してねw

2010-08-13

http://anond.hatelabo.jp/20100813021101

つ http://revilog.com/2010/08/c-fizzbuzz-printf.html

#include <stdio.h>

int main(void){
    int i;
    for(i = 1 ; i <= 100 ; i++){
        printf("%d \0Fizz \0FizzBuzz "+(i%5?(i%3?0:4):(i%3?14:10)),i);
    }
    printf("\n");
    return 0;
}

有効行数的{}を取るとか 以外で、これよりもFizz Buzzを短く出来る?

2010-07-24

google発のProtocol Buffersについて

オブジェクトシリアライズツールであるプロトコルバッファについて書きます。

プロトコルバッファって何って方はこちらへ

Protocol Buffers 本家

http://code.google.com/apis/protocolbuffers/

XMLはもう不要!? Googleシリアライズツール「Protocol Buffer」

http://journal.mycom.co.jp/articles/2008/07/18/protocolbuffer/index.html

Protocol Buffers (Protocol Buffers の内部解説記事。とても参考になります)

http://dodgson.org/omo/t/?date=20080712

内容

プロトコルバッファは異種言語間でオブジェクトのやりとりをするための規格です。

独自の言語によりオブジェクトインターフェースを規定することで、多言語対応を行っています。

例えばこんな感じ。

  • address.proto
package tutorial;

message Person {
  required string name = 1;
  required int32 id = 2;        // Unique ID number for this person.
  optional string email = 3;

  enum PhoneType {
    MOBILE = 0;
    HOME = 1;
    WORK = 2;
  }

  message PhoneNumber {
    required string number = 1;
    optional PhoneType type = 2 [default = HOME];
  }

  repeated PhoneNumber phone = 4;
}

// Our address book file is just one of these.
message AddressBook {
  repeated Person person = 1;
}

以上のようなprotoファイルから各言語ソースコード、または何らかのデータ操作ライブラリを使いオブジェクトの処理を行います。

googleによってC++, Java, Python用のライブラリ作成されましたが、他の言語対応したサードパーティー製のライブラリがいくらでもあるので、実質的にほぼすべての言語で使えると言っても過言ではありません。

以下はこのライブラリを使ってみた感想などです。

整数型はVarintという可変長型でバイナリに保存される

数字が多きければ大きいほど、長いバイト長で保存されます。ただし、負数の場合符号ビットが立つ関係で、ほとんど常に変換後のバイト数が最長バイト数(10)になってしまいます。フィールドの型をsint32, sint64で宣言しると、各数値にzig-zags変換が行われるため、負数であってもその値の絶対値で使用バイト数が決まるようになります。

保存されるデータは各メッセージID/型/値のみ

バイナリに保存されるデータは各メッセージID/型/値のみです。なので、同じ定義の二つのメッセージ型は、プロトコルバッファ上では全く同じように扱うことが出来ます。例えば、片方からシリアライズしたデータを、もう片方の型でデシリアライズすることが可能です。

またオブジェクト連続シリアライズ/デシリアライズすることもできます。

継承されたクラスマッピング

すでに存在する継承関係のあるクラスを、Protocol Buffersでシリアライズ/デシリアライズしたい場合は次のようにします。

(Base, Derived はすでに存在するとします)

(ソースコード中になぜか日本語が書けないので、コメントはすべて英語になっています)

message PbBase {
        require int32 id = 1;
        require int32 value = 2;

        require Derived derived = 10; // - Point !!!
}

message PbDerived {
        require string string_value = 1;
}

継承元のメッセージ定義に、継承先のメッセージを持たせます。Base継承するクラスシリアライズ/デシリアライズしたい場合は、PbBaseメッセージを中心に処理を行うことで、比較的簡単に処理を実装することが出来ます。

例えばこんな感じ

Base *Base_DeserializeFrom(PbBase &pbobj)
{
    // Arrange the classes which inherits from Base.
    if (pbobj.has_derived()) {
        return new Derived(pbobj);
    }
    else
    ...
}

class Base {
    ...
    virtual void Base::SerializeTo(PbBase &pbobj) {
        // Set the fields of 'pbobj',
    }
    ...
};

class Derived {
    ...
    virtual void Base::SerializeTo(PbBase &pbobj)
    {
        PbDerived *derived = pbobj.mutable_derived();

        Base::SerializeTo(pbobj);
        // Set the fields of 'derived',
        ...
    }
    ...
};

protoファイルを以下のように書くと、メッセージの扱いが非常に難しくなります。

message PbBase {
        require int32 id = 1;
        require int32 value = 2;
}

message PbDerived {
        required PbBase base = 1; // - Here is the point !!!
        require string string_value = 2;
}

2010-06-09

このような悲劇を繰り返さないために!

お主にはこの秘伝のブックマークレットを授けよう。

返信したい増田の記事で使い給え。

javascript:void(window.open('http://anond.hatelabo.jp/ここに自分ユーザー名/edit?title='+escape(location.href),'_blank'));

2010-05-24

懐かしい

voidさんが居るのかと思った。

2010-03-21

プログラマーの皆様にお聴きしたいです

こんなプログラムがあります。

int main(void) {

 printf("Hello ");

 if (fork() == 0) {

  printf("World\n");

 }

 return (0);

}

これの表示が

Hello World

にならないのはプログラマー常識の範囲内でしょうか?



元ネタhttp://nostarch.com/extras/hownotc/hello7_c.html

2010-01-14

http://anond.hatelabo.jp/20100113192313

これで40分。

タイムアタックってことでアルゴリズムは全幅探索で書き上げました。

エラーチェック皆無。

A*ならもう5分ほど延びるかな?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Maze
{
    class Program
    {
        // 探索用地図
        static int[,] maze;

        // 始点終点
        static Position Start = new Position(0, 0), Goal = new Position(0, 0);

        static void Main(string[] args)
        {
            //////////////////////////// まずは各行のリストとして読み込み
            string[] inMaze;

            using (var fp = new FileStream(args[0], FileMode.Open, FileAccess.Read))
            using (var iStream = new StreamReader(fp))
                inMaze = iStream.ReadToEnd().Split('\n');

            // 迷路幅
            int height = inMaze.Length;

            // 迷路高さ
            int width = inMaze[0].Length;

            /////////////////////////// 読み込んだ迷路を作業用地図に展開
            maze = new int[width, height];
            for (int y = 0; y < height; ++y)
            {
                string line = inMaze[y];
                for (int x = 0; x < line.Length; ++x)
                {
                    maze[x, y] = line[x] == '*'
                        ? -1
                        : 0;
                    if (line[x] == 'S') Start = new Position(x, y);
                    if (line[x] == 'G') Goal = new Position(x, y);
                }
            }

            // 探索実行
            int dist = Search(maze, Start);

            // 探索結果から最短経路を再現
            Position backTracer = Goal;
            while (dist&gt;1){
                --dist;
                backTracer = backTracer.Nearbys.First(pos =&gt; maze[pos.X,pos.Y] == dist);
                maze[backTracer.X, backTracer.Y] = -2;
            }

            //////////////////// 最短経路こみのアスキー地図に変換
            char[,] outMaze = new char[width, height];

            for (int y = 0; y < height; ++y)
            {
                for (int x = 0; x < width; ++x)
                {
                    outMaze[x, y] = maze[x, y] == -2
                        ? '$'
                        : maze[x, y] == -1
                            ? '*'
                            : ' ';
                }
            }
            outMaze[Start.X, Start.Y] = 'S';
            outMaze[Goal.X, Goal.Y] = 'G';


            ////////////////////// 結果は標準出力に。
            for (int y = 0; y < height; ++y)
            {
                for (int x = 0; x < width; ++x)
                    Console.Write(outMaze[x, y]);
                Console.WriteLine();
            }
            Console.ReadLine();
        }

        /// <summary&gt;
        /// 探索する。SG間の道のりを返す(道のり=SGが隣接しているなら1)
        /// </summary&gt;
        private static int Search(int[,] maze, Position Start)
        {
            List<Position&gt; FrontLine = new List<Position&gt;();
            FrontLine.Add(Start);
            int dist = 1;
            for (; ; )
            {
                List<Position&gt; NextFrontLine = new List<Position&gt;();
                foreach (var pos in FrontLine)
                {
                    foreach (var nextPos in pos.Nearbys)
                    {
                        if (nextPos == Goal) return dist;
                        if (maze[nextPos.X, nextPos.Y] == 0)
                        {
                            maze[nextPos.X, nextPos.Y] = dist;
                            NextFrontLine.Add(nextPos);
                        }
                    }
                }
                FrontLine = NextFrontLine;
                ++dist;
            }
        }
    }

    struct Position
    {
        public readonly int X, Y;
        public Position(int x, int y) { X = x; Y = y; }

        public IEnumerable<Position&gt; Nearbys
        {
            get
            {
                return new[]{
                    new Position(X-1,Y),
                    new Position(X,Y-1),
                    new Position(X+1,Y),
                    new Position(X,Y+1),
                };
            }
        }

        public static bool operator==(Position p1, Position p2){
            return p1.X == p2.X &amp;&amp; p1.Y == p2.Y;
        }

        public static bool operator!=(Position p1, Position p2){
            return p1.X != p2.X || p1.Y != p2.Y;
        }
    }
}
- 転職ならen
- 派遣ならen
4ページ中1ページ目を表示(合計:96件)