示例#1
0
文件: test2014_03.C 项目: 8l/rose
int main()
   {
  // Discretization specification.

  // First-order forward and backward discretization operators (primatives) for the X-axis
     D_plus dpx(0);
     D_minus dmx(0);

  // Build a second order operator (X-axis)
     Operator DPDMx = dpx(dmx);

  // First-order forward and backward discretization operators (primatives) for the Y-axis
     D_plus dpy(1);
     D_minus dmy(1);

  // Build a second order operator (Y-axis)
     Operator DPDMy = dpy(dmy);

  // Build the multidimensional (2D) second order operator (X-axis and Y-axis)
     Operator Laplace2D = DPDMx + DPDMy;

  // Build data on which to apply operator.
     GridFunction u,v;

  // Initialize the data
     u = 0.0;

  // Application of stencil on u saved in v.
     v = Laplace2D(u);

  // Output data in v.
     v.print();
   } 
示例#2
0
 ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
     ListNode dmy(0), *cur = &dmy;
     int carry = 0;
     while (carry || l1 || l2) {
         int sum = carry + (l1 ? l1->val : 0) + (l2 ? l2->val : 0);
         carry = sum/10;
         cur->next = new ListNode(sum%10);
         cur = cur->next;
         l1 = (l1 ? l1->next : l1);      // one line if
         l2 = (l2 ? l2->next : l2);
     }
     return dmy.next;          // return head address
 }