Advertisement
Ne-Biolog

Untitled

May 7th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <memory.h>
  4. #include <iterator>
  5. #include <cassert>
  6. #include <fstream>
  7. #include <iomanip>
  8. #include <cstdlib>
  9. #include <bitset>
  10. #include <vector>
  11. #include <cstdio>
  12. #include <string>
  13. #include <queue>
  14. #include <deque>
  15. #include <cmath>
  16. #include <ctime>
  17. #include <stack>
  18. #include <set>
  19. #include <map>
  20.  
  21. using namespace std;
  22.  
  23. //#define int long long
  24.  
  25. #define fi first
  26. #define se second
  27. #define pb push_back
  28. #define mp make_pair
  29. #define all(x) x.begin() , x.end()
  30.  
  31. typedef long long ll;
  32. typedef long double ld;
  33. typedef pair < ll , ll > pll;
  34. typedef pair < int , int > pii;
  35.  
  36. template < typename T >
  37. T read(){
  38. T p = 1 , x = 0;
  39. char s = getchar();
  40. while(s == ' ' || s == '\n') s = getchar();
  41. if(s == '-') p = -1 , s = getchar();
  42. while(s >= '0' && s <= '9'){
  43. x = x * 10 + s - '0';
  44. s = getchar();
  45. }
  46. return x * p;
  47. }
  48.  
  49. template < typename A , typename B >
  50. void Umax(A &a , const B &b){
  51. if(a < b)
  52. a = b;
  53. }
  54.  
  55. template < typename A , typename B >
  56. void Umin(A &a , const B &b){
  57. if(a > b){
  58. a = b;
  59. }
  60. }
  61.  
  62. ll bin_pow (ll a , ll n) {
  63. if(n == 0){
  64. return 1;
  65. }
  66. if(n % 2 == 1){
  67. ll cnt = a * bin_pow(a , n - 1);
  68. return cnt;
  69. }
  70. else {
  71. ll cnt = bin_pow(a , n / 2);
  72. return cnt * cnt;
  73. }
  74. }
  75.  
  76. const int N = (int) 2e5 + 10;
  77. const int MOD = (int) 1e9 + 7;
  78. const int INF = (int) 1e9 + 10;
  79. const ll LLINF = (ll) 1e18 + 10;
  80. const int dx [] = { 0 , 0 , 1 , -1 };
  81. const int dy [] = { 1 , -1 , 0 , 0 };
  82.  
  83. bool isLetter(char c) {
  84. if(c >= 'a' && c <= 'z') return true;
  85. if(c >= 'A' && c <= 'Z') return true;
  86. return false;
  87. }
  88.  
  89. int main ()
  90. {
  91. freopen("input.txt" , "r" , stdin);
  92. freopen("output.txt" , "w" , stdout);
  93. ios_base::sync_with_stdio(false);
  94.  
  95. int *lenOfWords = NULL;
  96. char **listOfWords = NULL;
  97. char *currWord = (char*)malloc(sizeof(char) * 100);
  98.  
  99. char ch = 'q';
  100. int numberOfWordsInFileN1 = 0;
  101.  
  102.  
  103. while(true) {
  104. if(ch == EOF) break;
  105. ch = getchar();
  106.  
  107. if(isLetter(ch)) {
  108. int currLen = 0;
  109. currWord[currLen] = ch;
  110. cout << currWord[currLen];
  111. while(true) {
  112. ch = getchar();
  113. if(isLetter(ch)) {
  114. currLen++;
  115. currWord[currLen] = ch;
  116. cout << currWord[currLen];
  117. } else break;
  118. }
  119. cout << endl;
  120. numberOfWordsInFileN1++;
  121.  
  122. lenOfWords = (int*)realloc(lenOfWords, numberOfWordsInFileN1 * sizeof(int));
  123. lenOfWords[numberOfWordsInFileN1 - 1] = currLen + 1;
  124.  
  125. listOfWords = (char**)realloc(listOfWords, numberOfWordsInFileN1 * sizeof(char*));
  126. listOfWords[numberOfWordsInFileN1 - 1] = (char*)malloc(sizeof(char) * (currLen + 1));
  127. for(int i = 0; i < currLen; ++i) {
  128. //cout << currWord[i];
  129. listOfWords[numberOfWordsInFileN1 - 1][i] = currWord[i];
  130. }
  131. //cout << endl;
  132. }
  133. }
  134.  
  135. for(int i = 0; i < numberOfWordsInFileN1; ++i) {
  136. for(int j = 0; j < lenOfWords[i]; ++j) {
  137. cout << listOfWords[i][j];
  138. }
  139. cout << endl;
  140. }
  141.  
  142.  
  143.  
  144. return 0;
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement