求助

P1307 [NOIP2011 普及组] 数字反转

TeaWine @ 2020-11-05 22:52:11

#include <iostream>

#include <string>

using namespace std;

int main () {

    int p;

    bool o=1;

    string num, nom;

    cin>>num;

    for(int i = 0; i<=num.size(); i++) 
    {

        nom [p] = num [i];

        p++;

    }

    for(int i = 0; i<=nom.size(); i++)
    {

    if(o&&nom [i]-32) continue; //去0

        if(!nom [i]) o=0; 

        cout<<nom [i];

    }

    return 0;
}

什么都不输出


by lzh(高仿) @ 2020-11-05 23:17:27

额,那个p没赋值,取了随机数,所以p很大


by TeaWine @ 2020-11-14 11:20:15

谢谢dalao提醒 突然发现思路不对


|