Thursday, October 31, 2013

Sieve of Eratosthenes C++

I think Wikipedia has introduced it very clearly, and I implemented it on my machine with Code::Block. It works quite well.

#include <stdio.h>
#include <math.h>

#define MAX 1000001

int main()
{
    int i=0, j=0, m=0;
    bool prime[MAX]={0};

    for(i=2; i<MAX; ++i) prime[i] = (i & 1);

    m = sqrt(MAX);
    for(i=3; i<=m; i+=2)
    {
        if (prime[i])
        {
            for(j=i*i; j<MAX; j+=i) prime[j] = false;
        }
    }

    scanf("%d", &m);
    for(i=2; i<m; ++i)
    {
        if (prime[i]) printf("%d ",i);
    }

    return 0;
}




Monday, October 28, 2013

Get Qt Installed in Visual Studio 2010

It's a little weird for me to use Qt in Visual Studio 2010. The first time I programmed with Qt is about May in 2013 and the IDE was Qt Creator in Ubuntu. With a book borrowed from library, I began my Qt tour. Since then I get accustomed to Qt Creator. Today I have to try something new in VS2010, although I have threw away VS for a long time and replaced it with code::block or others. OK, let's do some stuff now.

1. Download Qt-4.7.4-VS2008 (I chose this version) from its official site 
2. Download Qt-VS-AddIn 
3. Install them and try to build a new project in VS2010


You can choose what you need from here whatever Qt Creator, Qt libraries or others .


Sunday, October 27, 2013

Install MSDN for Visual Studio 2010

Recently I was back to Visual Studio to program and I uninstalled my code::block and installed VS2010. Given the poor network efficiency, installing local MSDN helps a lot. The whole process is recorded as below:

1. Open Visual Studio 2010
2. Press "Ctrl" + "F1" to check installing method for current version
3. Open "Help Library Manager"
4. Do some basic setting
5. Choose installing from local files
6. Add what you like

OK, that's all. So easy, huh?

Sunday, October 6, 2013

HTML5 & CSS3 FOR THE REAL WORLD

I'm a beginner in front-end web development. Many of my classmates don't care about their website because they think it is the work of those who have a talent in aesthetic and are good at designing. However, they don't even intend to know how to write those codes like html, css and js. In my opinion, though we may be not as great as people who have an artistic talent or get professional training, it's necessary for us to understand and write front-end codes. So today I just borrowed a book from library, that is "HTML5 & CSS3 FOR THE REAL WORLD".

I read through the first, second and third chapters very fast for their difficulties in understanding for such a beginner as me. In other words, the fourth chapter is my first chapter. Let me keep track of my reading in the following way, and I think it is clear and efficient :-)


<label for="name">My name is: </label>
<input type="text" id="name" name="name" required aria-required="true">


<label for="name">My name is: </label>
<input type="text" id="name" name="name" placeholder="Scrooge Santa">


<label for="password">Set my password as:</label>
<p>(at least six characters, no space)</p>
<input type="password" id="password" name="password" required aria-required="true" pattern="\S{6,20}">


<label for="about">article title</label>
<input type="text" name="about" id="about" 
placeholder="First time reading" readonly>


<label for="favcolor">Favorite Color</label>
<input type="text" list="colors" id="favcolor" name="favcolor">
<datalist id="colors">
<option value="Blue">
<option value="Green">
<option value="Pink">
<option value="Purple">
</datalist>


<form id="search" method="get">
<input type="search" id="s" name="s">
<input type="submit" value="Search">
</form>


<label for="address">My email address is:</label>
<input type="email" id="address" name="address" required aria-required="true">


<label for="url">My website is:</label>
<input type="url" id="url" name="url">


<label for="rating">On a scale of 1 to 10, my knowledge is :</label>
<input type="range" min="1" max="10" id="rating" name="rating">


<label for="startdate">Start my subscription on:</label>
<input type="date" min="2000-01-01" max="2099-12-31" id="startdate" name="startdate" placeholder="2013-9-2">