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代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int *p,*q,m,n;
int ans;
p=&m;
q=&n;
while(scanf("%d%d",p,q)!=EOF)
{
ans=*p+*q;
printf("%d\n",ans);
}
return ;
}