nyoj A+B Problem(V)

来源:互联网 发布:办公软件教学计划 编辑:程序博客网 时间:2024/06/06 14:41

A+B Problem(V)

时间限制:1000 ms  |  内存限制:65535 KB
难度:1
描述
做了A+B Problem之后,Yougth感觉太简单了,于是他想让你求出两个数反转后相加的值。帮帮他吧
输入
有多组测试数据。每组包括两个数m和n,数据保证int范围,当m和n同时为0是表示输入结束。
输出
输出反转后相加的结果。
样例输入
1234 1234125 1170 0
样例输出
86421232
#include<iostream>#include<string.h>#include<stdio.h>#include <stdlib.h>using namespace std;int main(){int  a,b;   while(cin>>a>>b)      {      int m,n,x=0,y=0;  if(a==0&&b==0)     break;       while(a)   {      x=x*10+a%10;      a/=10;   }      while(b)   {     y=y*10+b%10;     b/=10;   }      cout<<x+y;   cout<<endl;         }  return 0;} 
   从这道题中发现在int型转char 型的方法 
   #include<iostream>#include <stdio.h>#include <string.h>#include <stdlib.h>  //itoa函数的头文件!!! using namespace std; int main(){    int num;    char str[20];    cin>>num;    itoa(num, str,10 );    cout<<str;    return 0;}
  但是itoa函数中 10 数字不明白什么意思 以后再看
0 0
原创粉丝点击