Код
// 2_1.cpp : Defines the entry point for the console application.
//include "stdafx.h"
#include <fstream>
#include <iostream>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
class Stack
{
static const int MAX = 80;
int st[MAX];
int top;
public:
Stack()
{
top=0;
}
void push (int var)
{
st[++top]=var;
}
int pop( )
{
return st[top--];
}
};
int main()
{
Stack s1;
const int MAX=80;
char buffer[3][MAX];
int i=0;
int x,j,dlina,k;
char z;
ifstream infile("input.txt");
while (!infile.eof())
{
infile.getline(buffer[i],MAX);
cout << buffer[i] << endl;
i++; //считали данные в массив строк
};
k=0;
dlina=0;
for (i=0;i<3;i++)
{
x=strlen(buffer[i]);
dlina=dlina+x;
for (j=0;j<=x;j++) //данные из массива помещаем в стек
{
s1.push(buffer[i][j]);
k++;
};
};
for (z='A';z<='Z';z++)
{
for (i=0;i<=k;i++) //выводим данные из стека в алфавитном
{
if ((s1.pop()==z)||(s1.pop()==(z+32)))
{
cout << s1.pop() << endl << "\n";
};
};
};
return 0;
}
//include "stdafx.h"
#include <fstream>
#include <iostream>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
class Stack
{
static const int MAX = 80;
int st[MAX];
int top;
public:
Stack()
{
top=0;
}
void push (int var)
{
st[++top]=var;
}
int pop( )
{
return st[top--];
}
};
int main()
{
Stack s1;
const int MAX=80;
char buffer[3][MAX];
int i=0;
int x,j,dlina,k;
char z;
ifstream infile("input.txt");
while (!infile.eof())
{
infile.getline(buffer[i],MAX);
cout << buffer[i] << endl;
i++; //считали данные в массив строк
};
k=0;
dlina=0;
for (i=0;i<3;i++)
{
x=strlen(buffer[i]);
dlina=dlina+x;
for (j=0;j<=x;j++) //данные из массива помещаем в стек
{
s1.push(buffer[i][j]);
k++;
};
};
for (z='A';z<='Z';z++)
{
for (i=0;i<=k;i++) //выводим данные из стека в алфавитном
{
if ((s1.pop()==z)||(s1.pop()==(z+32)))
{
cout << s1.pop() << endl << "\n";
};
};
};
return 0;
}