Blue Bridge Cup ALGO-107 9-7 linked list data summation operation (linked list)

Source: Internet
Author: User

"Idea": the direct addition of the test data is the line. But I still want to try the list, data structure after a year does write a little trouble. Alas.

Note: The spelling of the node link. And p->p at the time of traversal, skimming the head node.

"AC Code":

#include <iostream> #include <algorithm> #include <string> #include <cstdio> #include < cstring>using namespace std; #define MAX 10struct node{double a;double b; Node *next;}; int main () {freopen ("In.txt", "R", stdin); int i = 0; Node *p; Node *q = p;p = q = (node*) malloc (sizeof (node)); for (i = 0; i < MAX; i++) {Node *node;node = (node*) malloc (sizeof (node)) ; CIN >> node->a >> node->b;q->next = node;q = node;} Q->next = null;double m = 0, n = 0;for (p = p->next; p! = NULL; p = p->next) {m = p->a + m;n = p->b + N;} cout << m << "+" << n << "i"; return 0;}


Blue Bridge Cup ALGO-107 9-7 linked list data summation operation (linked list)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.