fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4. using namespace std;
  5.  
  6. struct xau
  7. {
  8. string x;
  9. } typedef xau;
  10.  
  11. int ssXau (xau a, xau b)
  12. {
  13. //Make same as length =102;
  14. while (a.x.length()!=102) a.x='0'+a.x;
  15. while (b.x.length()!=102) b.x='0'+b.x;
  16. for (int i=0; i<102; i++)
  17. {
  18. int ai=a.x[i]-'0';
  19. int bi=b.x[i]-'0';
  20. if (ai>bi) return 0;
  21. if (ai<bi) return 1;
  22. }
  23. return 1;
  24. }
  25.  
  26. string chXau (string a) //chuan hoa Xau
  27. {
  28. int vt=-1;
  29. for (int i=0; i<a.length(); i++)
  30. {
  31. if (a[i]!='0')
  32. {
  33. vt=i;
  34. break;
  35. }
  36. }
  37. if (vt==-1) return "0";
  38. else if (vt!=0)
  39. {
  40. string tg="";
  41. for (int i=vt; i<a.length(); i++) tg+=a[i];
  42. return tg;
  43. } else return a;
  44. }
  45.  
  46. int main ()
  47. {
  48. //IN;
  49. int N;
  50. cin>>N;
  51. string s;
  52. xau SX[502];
  53. int sl=0;
  54. for (int k=1; k<=N; k++)
  55. {
  56. cin>>s;
  57. //OUT;
  58. for (int i=0; i<s.length(); i++)
  59. {
  60. if ('0'<=s[i] && s[i]<='9')
  61. {
  62. string tg="";
  63. for (int j=i; j<s.length(); j++)
  64. {
  65. i=j;
  66. if ('9'<s[j] || s[j]<'0') break;
  67. else tg+=s[j];
  68. }
  69. sl++;
  70. SX[sl].x=tg;
  71. }
  72. }
  73. }
  74. // Sap xep;
  75. sort (SX+1, SX+sl+1, ssXau);
  76. for (int i=1; i<=sl; i++)
  77. {
  78. cout<<chXau (SX[i].x)<<endl;
  79. }
  80.  
  81. return 0;
  82. }
Success #stdin #stdout 0s 15256KB
stdin
4

43silos0

zita002

le2sim

231233
stdout
0
2
2
43
231233