SHARE
TWEET

Untitled

a guest Dec 19th, 2018 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //-------------------------------------------------------------------------—
  2.  
  3. #include <vcl.h>
  4. #pragma hdrstop
  5. #pragma argsused
  6. #include <iostream>
  7. #include <string>
  8. #include <stdio.h>
  9. #include <windows.h>
  10.  
  11.  
  12. //-------------------------------------------------------------------------—
  13.  
  14. #pragma argsused
  15. using namespace std;
  16.  
  17. int i,j,t;
  18. char s[255];
  19. int k;
  20. bool o;
  21. string a[99];
  22.  
  23. void sort(int n, int m) {
  24. string stroka;
  25. stroka=a[m];
  26. a[m]=a[n-m];
  27. a[n-m]=stroka;
  28. m++;
  29. if (m<=n/2) sort(n,m);
  30. }
  31.  
  32. int protivopol(int k, int i) {
  33. while(i<=t){
  34. o=true;
  35. for (j=0; j<strlen(a[i].c_str());++j)
  36. if ((int(a[i][j])<48) | (int(a[i][j])>57)) o=false;
  37. if (o==true) {k = atoi(a[i].c_str()); break; }
  38. i++;}
  39. return 0-k;}
  40.  
  41. int main() {
  42. SetConsoleOutputCP(1251);
  43. SetConsoleCP(1251);
  44.  
  45. cout«"Vvedite text:\n"; gets(s);
  46. int p = strlen(s), i = 0,cs=0;
  47. int count = 0;
  48.  
  49.  
  50.  
  51. while(i < p)
  52. {
  53.  
  54. if (s[i] != ' ' && (s[i + 1] == ' ' || s[i +1] == '\0'))
  55. {
  56. count++;
  57.  
  58. }
  59. i++;}
  60. cout«endl «"Kolichestvo slov: " «count«"\n";
  61.  
  62.  
  63.  
  64. t = 0;
  65. for (i=0; i<strlen(s);++i) {
  66. if (int(s[i])!=32) a[t] += s[i];
  67. else t++; }
  68.  
  69. k = protivopol(0,0);
  70. sort(t,0);
  71.  
  72. for (i=0; i<1+t; i++)
  73. cout«a[i]«" ";
  74.  
  75. if (o==true) cout«"\n"«"Pervoe chislo obratnim znacheniem = "«k«"\n";
  76.  
  77. system("pause");
  78. return 0; }
  79.  
  80.  
  81.  
  82. //---------------------------------------------------------------------------
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top