QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#36217#4286. 99 Problemscheems_is_hiringCompile Error//C++934b2022-06-26 00:08:052022-06-26 00:08:07

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:08:07]
  • 评测
  • [2022-06-26 00:08:05]
  • 提交

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(a <= 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:23:29: error: return-statement with no value, in function returning ‘int’ [-fpermissive]
   23 |         cout << 99 << endl; return;
      |                             ^~~~~~