program Project1; uses crt; const //Разделители слов. D = ['.', ',', ':', ';', '!', '?', '-', ' ', #9, #10, #13]; var S : String; i, Cnt, Len : Integer; begin repeat Writeln('Задайте строку:'); Readln(S); Len := Length(S); Cnt := 0; for i := 1 to Len do begin //Пропускаем разделители. if S[i] in D then Continue; //Отслеживаем начало слова. if (i = 1) or (S[i - 1] in D) then begin if S[i] in ['a', 'A'] then Cnt := Cnt + 1; end; end; Writeln('В заданной строке найдено ', Cnt, ' слов,'); Readln(S); until S <> ''; end.
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
class Rabotnik {
public:
Rabotnik() {
}
friend bool operator>(const Rabotnik &obj_Company, const Rabotnik &obj_Company2);
int workExperience;
string lastName;
string name;
string specialty;
int salary;
};
bool operator>(const Rabotnik &obj_Company, const Rabotnik &obj_Company2) {
return obj_Company.workExperience > obj_Company2.workExperience;
}
int main() {
int N = 5;
int workExperience[N];
string lastName[N];
string name[N];
string specialty[N];
int salary[N];
for(int i = 0; i<N; ++i) {
cout << "[" << i << "] " << "w. exp: "; cin >> workExperience[i];
cout << "lastname: "; getline(cin, lastName[i]);
cout << "name: "; getline(cin, name[i]);
cout << "specialty: "; getline(cin, specialty[i]);
cout << "salary: "; cin >> salary[i];
}
Rabotnik obj_Company[N];
for(int i = 0; i<N; ++i) {
obj_Company[i].workExperience=workExperience[i];
obj_Company[i].lastName=lastName[i];
obj_Company[i].name=name[i];
obj_Company[i].specialty=specialty[i];
obj_Company[i].salary=salary[i];
}
for(int i = 0; i<1000; ++i) {
for(int i = 0; i<N-1; ++i) {
if(obj_Company[i]>obj_Company[i+1]) {
swap(obj_Company[i].workExperience, obj_Company[i+1].workExperience);
}
}
}
for(int i = 0; i<N; ++i) {
cout << obj_Company[i].lastName << " " << obj_Company[i].name << ", work experience: " << obj_Company[i].workExperience << endl;
}
}