QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#36216#4286. 99 Problemscheems_is_hiringCompile Error//C++934b2022-06-26 00:07:372022-06-26 00:07:38

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-06-26 00:07:38]
  • 评测
  • [2022-06-26 00:07:37]
  • 提交

answer

/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
   set<int> A;  
    for(int i = 1; i <= 10 ; i ++) {
        for(int j = 1 ; j <= 4 ; j ++) {
            A.insert( i * (pow(10,j)) -1);
        }
    }
    int a; cin >> a;
    if(x <= 99) {
        cout << 99 << endl; return;
    }
    int dis = 999999 , ans = -1;
    for(int x : A ) { 
        if(x >= a)
        if(abs(x - a) < dis) {
            dis = abs(x - a);
            ans = x;
        }
        
    }
    cout << ans << endl;
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:22:8: error: ‘x’ was not declared in this scope
   22 |     if(x <= 99) {
      |        ^
answer.code:23:29: error: return-statement with no value, in function returning ‘int’ [-fpermissive]
   23 |         cout << 99 << endl; return;
      |                             ^~~~~~