Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <memory.h>
- #include <iterator>
- #include <cassert>
- #include <fstream>
- #include <iomanip>
- #include <cstdlib>
- #include <bitset>
- #include <vector>
- #include <cstdio>
- #include <string>
- #include <queue>
- #include <deque>
- #include <cmath>
- #include <ctime>
- #include <stack>
- #include <set>
- #include <map>
- using namespace std;
- //#define int long long
- #define fi first
- #define se second
- #define pb push_back
- #define mp make_pair
- #define all(x) x.begin() , x.end()
- typedef long long ll;
- typedef long double ld;
- typedef pair < ll , ll > pll;
- typedef pair < int , int > pii;
- template < typename T >
- T read(){
- T p = 1 , x = 0;
- char s = getchar();
- while(s == ' ' || s == '\n') s = getchar();
- if(s == '-') p = -1 , s = getchar();
- while(s >= '0' && s <= '9'){
- x = x * 10 + s - '0';
- s = getchar();
- }
- return x * p;
- }
- template < typename A , typename B >
- void Umax(A &a , const B &b){
- if(a < b)
- a = b;
- }
- template < typename A , typename B >
- void Umin(A &a , const B &b){
- if(a > b){
- a = b;
- }
- }
- ll bin_pow (ll a , ll n) {
- if(n == 0){
- return 1;
- }
- if(n % 2 == 1){
- ll cnt = a * bin_pow(a , n - 1);
- return cnt;
- }
- else {
- ll cnt = bin_pow(a , n / 2);
- return cnt * cnt;
- }
- }
- const int N = (int) 2e5 + 10;
- const int MOD = (int) 1e9 + 7;
- const int INF = (int) 1e9 + 10;
- const ll LLINF = (ll) 1e18 + 10;
- const int dx [] = { 0 , 0 , 1 , -1 };
- const int dy [] = { 1 , -1 , 0 , 0 };
- bool isLetter(char c) {
- if(c >= 'a' && c <= 'z') return true;
- if(c >= 'A' && c <= 'Z') return true;
- return false;
- }
- bool stringСomparison(char *x, int sizeX, char*y, int sizeY) {
- if(sizeX != sizeY) return false;
- for(int i = 0; i < sizeX; ++i) {
- if(x[i] != y[i]) return false;
- }
- return true;
- }
- void readTextFromFile(int *lenOfWords, char **listOfWords, int &numberOfWordsInFileN1) {
- char *currWord = (char*)malloc(sizeof(char) * 100);
- char ch = 'q';
- while(true) {
- if(ch == EOF) break;
- ch = getchar();
- if(isLetter(ch)) {
- int currLen = 0;
- currWord[currLen] = ch;
- while(true) {
- ch = getchar();
- if(isLetter(ch)) {
- currLen++;
- currWord[currLen] = ch;
- } else break;
- }
- currLen++;
- numberOfWordsInFileN1++;
- lenOfWords = (int*)realloc(lenOfWords, numberOfWordsInFileN1 * sizeof(int));
- lenOfWords[numberOfWordsInFileN1 - 1] = currLen;
- listOfWords = (char**)realloc(listOfWords, numberOfWordsInFileN1 * sizeof(char*));
- listOfWords[numberOfWordsInFileN1 - 1] = (char*)malloc(sizeof(char) * (currLen + 1));
- for(int i = 0; i < currLen; ++i) {
- listOfWords[numberOfWordsInFileN1 - 1][i] = currWord[i];
- }
- }
- }
- for(int i = 0; i < numberOfWordsInFileN1; ++i) {
- cout << lenOfWords[i] << ' ';
- for(int j = 0; j < lenOfWords[i]; ++j) {
- cout << listOfWords[i][j];
- }
- cout << endl;
- }
- }
- int main ()
- {
- freopen("input.txt" , "r" , stdin);
- freopen("output.txt" , "w" , stdout);
- ios_base::sync_with_stdio(false);
- int *lenOfWordsInFileN1 = NULL;
- char **listOfWordsInFileN1 = NULL;
- int numberOfWordsInFileN1 = 0;
- int *lenOfWordsInFileN2 = NULL;
- char **listOfWordsInFileN2 = NULL;
- int numberOfWordsInFileN2 = 0;
- readTextFromFile(lenOfWordsInFileN1, listOfWordsInFileN1, numberOfWordsInFileN1);
- re
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement