Sunday, November 1, 2015

Funny C Program:Zhishen Lu Eating Steamed Bun v1

Zhishen Lu,who is called "flower monk",is one of the 108 heroes in All Men Are Brothers,which is one of the Four Great Classical Novels of Chinese literature.It's said that he went to the daxiangguo temple in Prefecture of Kaifeng at a noon in a hurry to bum lunch.But there were only 99 steamed buns for 99 monks in the temple exactly.So what happened later?
The elder Zhiqing didn't want to offend Zhishen Lu,so he figured out a good idea.
Firstly,he arranged Zhishen Lu at a specific position.
Then,the elder said to all the people,"let's form a ring to number off beginning from me.The 5th men can get a steamed bun and leave."Other people continued to number off from 1 to 5,of course.
Finally,all men but Zhishen Lu ate a steamed bun.What a surprise!
Here comes the problem,"how did it happen?Or,where are Zhishen Lu?"
Smart friends,can you find the position number of Zhishen Lu?
As a matter of fact,I knew this story from a mooc teaching C programming.And I was prompted to use sieve method.Although prompted,I spent one day to find the correct answer.Too long,right?What's worse,I still have some doubts after knowing the answer.It appeared terrible,however,I learned a lot.
Now share my first version of the source code.

//Zhishen Lu Eating Steamed Bun v1
#include <stdio.h>
int main(void)
{
int monk[101]={0},count=0,steabun=0,i=0;//Easy to count.monk[1]~monk[100] for the flower monk Zhishen Lu and other 99 monks,value 0 means they will participate in numbering off.count to number off,steabun for the number of steamed buns already divided and i as a simple counter.
while (steabun<99&&!monk[++i])
{
if (++count%5==0)
{
monk[i]=1;//Get a steamed bun
steabun++;
}
if (i==100)
i=0;//Next circle
}
for(i=1;monk[i];i++) ;//Do you know why ";" exists?
printf("The position number of Zhishen Lu is %d.\n",i);
return 0;
}

Through looking at it,do you find any problems.If not,debug or run it in person.
As a matter of fact,when I finnished this code,I was ecstatic,with great achievability of solving this problem.But quickly,I felt disappointed looking at the result printed on the screen,"The position number of Zhishen Lu is 1. "
Of course,it's wrong,for the elder was at the 1st position.How to correct?I was frustrated.Want to know more?Follow my posts next several days.
In addition,I wrote,compile,and run the code on C4droid on my Android phone,and my blogs are posted through the mobile phone,too.As the operations on the Android phone are limited,such as no debugger on it,so you can barely see pictures in my blogs,and the code was not highlighted.I'm sorry and embarrassed for my economic condition not to buy a computer.But I'm still glad to share.I hope you can gain something through reading my blogs.Thanks.

Saturday, October 31, 2015

What Do You Think About The Universal Two-Child Policy In China?

Several days ago,Communist Party of China Central Committee stated that the universal two-child policy would be implementated from then on,which means China further relaxed its family planning policy,whose history are more than 30years.
Maybe you thought the family planning policy beyond understanding.Then what do you think about the new policy?
Although it seemed unimaginable for the government to prevent families giving births to more children,it's under special backgroun,or the population of China today would be more unimaginable.On the other hand,to relax the family planning policy was a tendency,of course.
Are you afraid of population increasing of China since the universal two-child policy?Acturally,the era is chaging,and concepts of people are changing,too.The costs to bring up a child are becoming more and more,especially in urban areas.And there are also some other factors that impact the concepts of people.So it's time to carry out the universal two-child policy in China.
What's your opinion?Mind sharing with us?

Thursday, October 29, 2015

Go After Your Interest,and Realize Your Dream

I posted a blog yesterday discussing whether it's worthy to go to university.And I did also say that I won't stop schooling.But it's really hard for me to learn my major related to biology,which was transferred by my school.
The biggest problem comes from low interest.In fact,I am good at logical thinking while not memorizing,so the scores of some of my courses such as higher mathematics and linear algebra are very high,but those of professional courses are relatively low.As a result,I have started to learn programming and software development by myself.I think it's interesting to make the computer work as you want.
I will go after my interest and keep trying to realize my dream to be a programmer.And what about you?
If you are a programmer,I need your advice,of course.Thank you!

Wednesday, October 28, 2015

Go to University:Worthy or Not?

The author is a university student,but I'd like to announce that posting this blog does not mean the idea to discontinue my schooling.Ha-ha!
The inspiration of this blog came from an article I read several days ago,Americans Also Ask:Whether It Is Worthful to Pay for University,a Chinese version of John Cassidy's article published on The New Yorker on September 7th.Following are my own opinions.
On one hand,education is very wonderful and there are many world-famous universities in America,which is considered the superpower.Should studying in those universities be full of happiness?What's more,learning what we didn't know before,regardless of which universities we are in,can improve our quality undoubtedly.As to the costs,will Americans be worried about this problem?"There’s no doubt that college graduates earn more money, on average, than people who don’t have a degree."Why not go to university?
On the other hand,through this article,I know that Americans who didn't go to university can also earn lots of money(compared to that of developing countries).It seems that whether go to university or not doesn't impact one's living significantly and it's not necessary to pay for university.
In America,it's optional.However,in some other countries,education background is essential when looking for a job,so universities increase enrollment constantly and higher education becomes more and more common.As a result,the amount of graduates increases sharply,the employment pressure is higher,too.
Effective solutions need to be proposed.