online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
# response to https://python-forum.io/Thread-Print-one-line-in-dictionary data = ( [('ID', '10652'), ('Time', '2018/12/11 02:30')], \ [('ID', '10653'), ('Time', '2018/12/11 03:30')], \ [('ID', '10654'), ('Time', '2018/12/11 04:30')], \ [('ID', '10655'), ('Time', '2018/12/11 05:30')] ) # search all, data may not be sorted def search_id( id_num ): ids = str(id_num) for record in data: if record[0][1]==ids : return record return None # search to id not higher, if data is sorted by id # (some records can be missing) def to_id( id_num ) : ids = str(id_num); length = len(data); i = 0 while i<length : if data[i][0][1] < ids : i += 1 elif data[i][0][1] == ids : return data[i] else : return None print( search_id(10652) ) # [('ID', '10652'), ('Time', '2018/12/11 02:30')] print( to_id (10653) ) # [('ID', '10653'), ('Time', '2018/12/11 03:30')] # if you have sorted data without missing records # you can calculate index of searched row like zero = int(data[0][0][1]) print( data[10654 -zero] ) # [('ID', '10654'), ('Time', '2018/12/11 04:30')] #----------- # you have not dictionary, but if you may change data format # to dictionary, like data = { 10652: [('ID', '10652'), ('Time', '2018/12/11 02:30')], \ 10653: [('ID', '10653'), ('Time', '2018/12/11 03:30')], \ 10654: [('ID', '10654'), ('Time', '2018/12/11 04:30')], \ 10655: [('ID', '10655'), ('Time', '2018/12/11 05:30')] } # you can address records: print(data[10655] ) # [('ID', '10655'), ('Time', '2018/12/11 05:30')]

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue