Jeffrey&Lynny

一个温馨小家庭的.Net生活

导航

Programming Pearls: Chatper3 Problem3 [Print Banner]

ProgrammingPearlsChapter3Problem3 

The output is like this:

xxxxxxxxx
xxxxxxxxx
      xx
     xx
    xx
   xx
  xx
 xx
xxxxxxxxx
xxxxxxxxx


xxxxxxxxx
xxxxxxxxx
xxxxxxxxx
   xxx
   xxx
   xxx
   xxx
   xxx
   xxx
xxxxxxxxx
xxxxxxxxx
xxxxxxxxx

Lesson Learned:
1. When you define a local variable inside the loop {...}, it means that this variable will be initialized every time the loop executes.
2. isdigit() and isalpha() can be used to check if the item falls in the range we expected.
3. When you wrote the loop using while, remember to advance the variable so that the loop can end:
while(*p!='\0')
{
    p++; //Remember to add this statement
}

posted on 2008-06-08 12:16  比尔盖房  阅读(311)  评论(0编辑  收藏  举报