XG 的个人资料Life, it seems, will fad...照片日志列表更多 工具 帮助
第 1 张,共 2 张

Q XG

职业
地点
兴趣

订阅源

所有者还没有为此模块指定订阅源。
作者 
作者 
作者 
作者 
作者 
作者 
作者 
作者 
作者 
作者 
作者 
作者 
作者 
作者 
作者 
作者 
作者 
作者 
作者 
作者 
作者 
作者 
Thanks for visiting!
请稍候...
很抱歉,您输入的评论太长。请缩短您的评论。
您没有输入任何内容,请重试。
很抱歉,我们当前无法添加您的评论。请稍后重试。
若要添加评论,需要您的家长授予您相应权限。请求权限
您的家长禁用了评论功能。
很抱歉,我们当前无法删除您的评论。请稍后重试。
您已超过了一天之内允许提供的评论数上限。请在 24 小时后重试。
因为我们的系统表明您可能在向其他用户提供垃圾评论,您的帐户已禁用了评论功能。如果您认为我们错误地禁用了您的帐户,请联系 Windows Live 支持部门
完成下面的安全检查,您提供评论的过程才能完成。
您在安全检查中键入的字符必须与图片或音频中的字符一致。

Life, it seems, will fade away

drifting further every day
2009/8/28

A better one

int hourMinuteHandInRight = 0;

int hourMinuteHandInLeft = 0;

int interval = 60;

int rightHand = 180 - interval;

int leftHand = 540 - interval;

while (hourMinuteHandInRight < 12 && hourMinuteHandInLeft < 12)

{

rightHand += interval;

if (rightHand == 660)

{

rightHand = 0;

hourMinuteHandInRight++;

}

Console.WriteLine("{0}:{1}", hourMinuteHandInRight, (int)(rightHand / 11));

hourMinuteHandInRight++;

leftHand += interval;

if (leftHand >= 660)

{

hourMinuteHandInLeft++;

leftHand = 0;

}

Console.WriteLine("{0}:{1}", hourMinuteHandInLeft , (int)(leftHand / 11));

hourMinuteHandInLeft++;

}

2009/8/27

Write a function to give out all the time (hour:minute) that the angle between minute hand and hour hand on a clock is 90 degree.

static void Main(string[] args)

{

for (int h = 0; h < 12; h++)

{

double m = 1.0;

double angle = 1.0

if (h < 9)

{

m = 1.0*(60 * h + 180) / 11;

angle = (m - h * 5 - m / 12) * 6;

Console.WriteLine("{0}:{1} {2}", h, (int)m, angle);

}

if (h > 9)

{

m = 1.0 * (60 * h - 540) / 11;

angle = (h * 5 + m / 12 - m) * 6;

Console.WriteLine("{0}:{1} {2}", h, (int)m, angle);

}

if (h < 3)

{

m = 1.0 * (60 * h + 540) / 11;

angle = (m - h * 5 - m / 12) * 6;

Console.WriteLine("{0}:{1} {2}", h, (int)m, angle);

}

if (h > 3)

{

m = 1.0 * (60 * h - 180) / 11;

angle = (h * 5 + m / 12 - m) * 6;

Console.WriteLine("{0}:{1} {2}", h, (int)m, angle);

}

}

}

2009/8/4

Traverse binary tree not recursively

       public static void PreOrder<T>(BinaryTreeNode<T> root, Action<BinaryTreeNode<T>> action)
        {
            if (root == null)
            {
                return;
            }
            Stack<BinaryTreeNode<T>> stack = new Stack<BinaryTreeNode<T>>();
            stack.Push(root);
            while (stack.Count != 0)
            {
                BinaryTreeNode<T> current = stack.Pop();
                if (current != null)
                {
                    action(current);
                }
                if (current.RightChild != null)
                {
                    stack.Push(current.RightChild);
                }
                if (current.LeftChild != null)
                {
                    stack.Push(current.LeftChild);
                }
            }
        }
 
public static void InOrder<T>(BinaryTreeNode<T> root, Action<BinaryTreeNode<T>> action)
        {
            if (root == null)
            {
                return;
            }
            Stack<BinaryTreeNode<T>> stack = new Stack<BinaryTreeNode<T>>();
            BinaryTreeNode<T> current = root;
            do
            {
                while (stack.Count != 0 && current == null)
                {
                    current = stack.Pop();
                    action(current);
                    current = stack.Pop();
                }
                if (current != null)
                {
                    stack.Push(current.RightChild);
                    stack.Push(current);
                    current = current.LeftChild;
                }
            } while (stack.Count != 0);
        }
 
        public static void LastOrder<T>(BinaryTreeNode<T> root, Action<BinaryTreeNode<T>> action)
        {
            if (root == null)
            {
                return;
            }
            Stack<BinaryTreeNode<T>> stack = new Stack<BinaryTreeNode<T>>();
            BinaryTreeNode<T> current = root;
            do
            {
                if (current.HasChildren)
                {
                    stack.Push(current);
                    if (current.LeftChild != null)
                    {
                        if (current.RightChild != null)
                        {
                            stack.Push(current.RightChild);
                        }
                        current = current.LeftChild;
                    }
                    else
                    {
                        current = current.RightChild;
                    }
                }
                else
                {
                    action(current);
                    while (stack.Count != 0 && current.IsChildrenOf(stack.Peek()))
                    {
                        current = stack.Pop();
                        action(current);
                    }
                    if (stack.Count != 0)
                    {
                        current = stack.Pop();
                    }
                }
            } while (stack.Count != 0);
        }

Link binary tree nodes at the same level

Given modified binary tree node
public class TreeNode<T>
{
    public TreeNode<T> LeftChild;
    public TreeNode<T> RightChild;
    public TreeNode<T> Right;
}
        public static void LinkEachLevel<T>(TreeNode<T> root)
        {
            LinkedList<TreeNode<T>> rightMost = new LinkedList<TreeNode<T>>();
            LinkedListNode<TreeNode<T>> first = new LinkedListNode<TreeNode<T>>(null);
            rightMost.AddFirst(first);
            LinkEachLevel(root, rightMost.First);
        }
 
        public static void LinkEachLevel<T>(TreeNode<T> node, LinkedListNode<TreeNode<T>> rightNode)
        {
            if (rightNode.Value != null)
            {
                node.Right = rightNode.Value;
            }
            rightNode.Value = node;
            if (rightNode.Next == null)
            {
                rightNode.List.AddLast(new LinkedListNode<TreeNode<T>>(null));
            }
            if (node.RightChild != null)
            {
                LinkEachLevel((TreeNode<T>)node.RightChild, rightNode.Next);
            }
            if (node.LeftChild != null)
            {
                LinkEachLevel((TreeNode<T>)node.LeftChild, rightNode.Next);
            }
        }
 
 
2008/9/1

Reporting Services中如何对数据进行分页合计?

Report services中不直接支持分页合计,实现这个功能得加些vb code(report code).
  • 右键report区域(BIDS中最外层的黄色区域),选择report properties;打开code tab.
  • 加入如下代码

public shared Dim _rowCount As Int32=0
public shared Dim _sum as Int32=0

public Function AddToRowCount() as Int32
 _rowCount = _rowCount + 1
 return _rowCount
End Function

public Function AddToSum(ByVal quantity as Int32) as Int32
 _sum+=quantity
 return quantity
End Function

public function GetSum() as Int32
 Dim currentSum= _sum
 _sum=0
 return currentSum
end function

public Function GetCurrentCountAndReset() As Int32
  Dim currentRowCount = _rowCount
  _rowCount = 0
  Return currentRowCount
End Function

  • 实现row index.

添加一个新列,设置它的expression为=Code.AddToRowCount

  • 实现quantity sum.

设计Quantity列(显示数额的列)的expression为=Code.AddToSum(Fields!Quantity.Value)

在Footer加入textbox, 并设置表达式为=Code.GetSum