online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <bits/stdc++.h> using namespace std; bool cmp(long long int a,long long int b){ return ((a%10)<(b%10)); } void solve(int n){ vector<long long int> nums(n); for (auto&x:nums)cin>>x; sort(nums.begin(),nums.end(),greater<long long int>()); stable_sort(nums.begin(),nums.end(),cmp); for (auto&x:nums)cout<<x<<' '; cout<<endl; } int main(){ int n; while (cin>>n)solve(n); return 0; }
#include <bits/stdc++.h> using namespace std; bool cmp(long long int a,long long int b){ return ((a%10)<(b%10));//比較個位數字大小(小到大) } void solve(int n){ vector<long long int> nums(n);//個人習慣用vector for (auto&x:nums)cin>>x;//輸入 sort(nums.begin(),nums.end(),greater<long long int>());//大到小排序 stable_sort(nums.begin(),nums.end(),cmp); //依個位數排序並保證同個位數時會是大到小 for (auto&x:nums)cout<<x<<' ';//輸出 cout<<endl; } int main(){ int n; while (cin>>n)solve(n);//多組測資 return 0; }

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