2012年4月17日 星期二

When She Was Mine

會不會其實你很困惑?

開始找不到文字來表達,所以我積極的聽歌。

2012年4月12日 星期四

[Java] How to INPUT

[Java]學習程式語言的第一支

好像頗好玩,閒來無事學習學習

package javaapplication1;
/*
 * @author Jay
 */
public class JavaApplication1 
{
    public static void main(String[] args) 
    {
        System.out.println("Hello ! World!");
    }
}

2012年4月3日 星期二

UVa 591

#include <cmath>

using namespace std;

int main()
{
    int n = 0, counter = 1;

    while ( cin >> n && n != 0 )
    {
        int *ptr, sum = 0, average = 0;
        ptr = new int [n];

        for (int i = 0; i < n; i++)
        {
            cin >> ptr[i];
            sum += ptr[i];
        }

        sum /= n;

        for (int i = 0; i < n; i++)
        {
            average += abs(sum - ptr[i]);
        }

        cout << "Set #" << counter << endl;
        cout << "The minimum number of moves is " << average / 2 << "." << endl << endl;

        counter++;
        delete [] ptr;
    }

    return 0;
}

UVa 476

#include <cmath>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    char word;
    int endPtr = 0, counter = 0;
    
    double ptr[11][5];
    for (int i = 0; i < 11; i++)
        for (int j = 0; j < 5; j++)
            ptr[i][j] = 0.0;
        
    while ( true )
    {
        cin >> word;
        if (word == '*')
        {
            endPtr = counter;
            break;
        }

        cin >> ptr[counter][1] >> ptr[counter][2] >> ptr[counter][3] >> ptr[counter][4];
        counter++;
    }

    double x = 0.0, y = 0.0;
    int dot = 1;
    while (cin >> x >> y && (x != 9999.9 && y != 9999.9))
    {
        bool have = true;
        for (int i = 0; i <= endPtr; i++)
        {
            if ( (x > ptr[i][1] && x < ptr[i][3] && (y > ptr[i][4] && y < ptr[i][2])))
            {
                cout << "Point " << dot << " is contained in figure " << i << endl;
                have = false;
            }
        }

        if ( have )
            cout << "Point " << dot << " is not contained in any figure" << endl;

        dot++;
    }


    return 0;
}