Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-------------------------------------------------------------------------—
- #include <vcl.h>
- #pragma hdrstop
- #pragma argsused
- #include <iostream>
- #include <string>
- #include <stdio.h>
- #include <windows.h>
- //-------------------------------------------------------------------------—
- #pragma argsused
- using namespace std;
- int i,j,t;
- char s[255];
- int k;
- bool o;
- string a[99];
- void sort(int n, int m) {
- string stroka;
- stroka=a[m];
- a[m]=a[n-m];
- a[n-m]=stroka;
- m++;
- if (m<=n/2) sort(n,m);
- }
- int protivopol(int k, int i) {
- while(i<=t){
- o=true;
- for (j=0; j<strlen(a[i].c_str());++j)
- if ((int(a[i][j])<48) | (int(a[i][j])>57)) o=false;
- if (o==true) {k = atoi(a[i].c_str()); break; }
- i++;}
- return 0-k;}
- int main() {
- SetConsoleOutputCP(1251);
- SetConsoleCP(1251);
- cout«"Vvedite text:\n"; gets(s);
- int p = strlen(s), i = 0,cs=0;
- int count = 0;
- while(i < p)
- {
- if (s[i] != ' ' && (s[i + 1] == ' ' || s[i +1] == '\0'))
- {
- count++;
- }
- i++;}
- cout«endl «"Kolichestvo slov: " «count«"\n";
- t = 0;
- for (i=0; i<strlen(s);++i) {
- if (int(s[i])!=32) a[t] += s[i];
- else t++; }
- k = protivopol(0,0);
- sort(t,0);
- for (i=0; i<1+t; i++)
- cout«a[i]«" ";
- if (o==true) cout«"\n"«"Pervoe chislo obratnim znacheniem = "«k«"\n";
- system("pause");
- return 0; }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement