HDU 1000 A + B Problem(指针版)

时间:2022-05-07
本文章向大家介绍HDU 1000 A + B Problem(指针版),主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

A + B Problem

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 654986    Accepted Submission(s): 204210

Problem Description

Calculate A + B.

Input

Each line will contain two integers A and B. Process to end of file.

Output

For each case, output A + B in one line.

Sample Input

1 1

Sample Output

2

Author

HDOJ

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1000

分析:我的第一道用指针做的题,初学指针,以前也从来没有用过指针,试试水,就来道A+B,大牛就不要喷了,Orz! 

下面给出AC代码:

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {
 5     int *p,*q,m,n;
 6     int ans;
 7     p=&m;
 8     q=&n;
 9     while(scanf("%d%d",p,q)!=EOF)
10     {
11         ans=*p+*q;
12         printf("%dn",ans);
13     }
14     return 0;
15 }