编译失败,求大佬调教

P1307 [NOIP2011 普及组] 数字反转

Swkt @ 2024-12-13 14:39:19

检查不出来,大佬看看

#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a;  
    while(a!=0)
    {
        b=b*10+a%10;
        a/=10; 
    }
    cout<b; 
    return 0; 
}

by wjr_jok @ 2024-12-13 14:43:34

好甜


by AllenJYL @ 2024-12-13 14:49:43

cout<b; 少了个 <


by Swkt @ 2024-12-13 14:52:56

@AllenJYL

#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a;  
    while(a!=0)
    {
        b=b*10+a%10;
        a/=10; 
    }
    cout<<b; 
    return 0; 
}

又全WA了!!


by Gumbo @ 2024-12-13 17:05:03

b 要初始化为 0


by Swkt @ 2024-12-18 20:01:17

谢谢大佬!已经100了!已关


|