Advertisement
Guest User

Code to output pictures of large penises

a guest
Nov 26th, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include<cstdlib>
  4. #include<string>
  5. #include<cmath>
  6. #include <stdlib.h>
  7.  
  8. using namespace std;
  9.  
  10.  
  11. void channelDecode(const string & input, string & fixed)
  12. {
  13. char A = 0;
  14.  
  15. for (unsigned int n = 0; n < input.size() - 1; n++)
  16. {
  17. A = A + input[n];
  18. }
  19.  
  20. if (A == input[input.size() - 1] )
  21. {
  22. fixed = input.substr(0, input.size() -1);
  23. }
  24. else
  25. {
  26. fixed = "Packet was corrupted and could not be decoded.";
  27. }
  28. return;
  29. }
  30.  
  31.  
  32. int parseLine(const string & line, const string & key)
  33. {
  34. int number1 = line.find(key);
  35. int number2 = line.length();
  36. if (number1 < 0 || number1 > number2)
  37. {
  38. return -9999;
  39. }
  40. string lineNew = line.substr(number1);
  41. return atoi(line.substr(number1 + 3, lineNew.find(' ') ).c_str() );
  42. }
  43.  
  44. string removeUnder(const string & input)
  45. {
  46. string inF = input;
  47. for(int i = 0; i < input.size(); i++)
  48. {
  49. if( input [i] == '_')
  50. {
  51. inF[i] = ' ';
  52. }
  53. else
  54. {
  55. inF[i] = input[i];
  56. }
  57. }
  58. return inF;
  59. }
  60.  
  61. int main()
  62. {
  63. ifstream infile("beacon.txt");
  64. ofstream outfile("beacon_clear.txt");
  65. string input;
  66. string fixed;
  67.  
  68. bool num = true;
  69.  
  70. do
  71. {
  72. getline(infile, input);
  73. if (infile.eof())
  74. {
  75. num = false;
  76. }
  77. else
  78. {
  79. fixed = input;
  80. channelDecode(input, fixed);
  81. outfile << fixed << endl;
  82. }
  83. }
  84. while(num);
  85. infile.close();
  86. outfile.close();
  87.  
  88. string bcline, iline, name, key, intitle, bctitle;
  89. int components, val;
  90.  
  91. ifstream beacon("beacon_clear.txt");
  92. ofstream result("result.txt");
  93. ifstream index("dataIndex.txt");
  94.  
  95. while(getline(beacon, bcline))
  96. {
  97. ifstream index("dataIndex.txt");
  98. if (bcline != "Packet was corrupted and could not be decoded.")
  99. {
  100. bcline.append(" ");
  101. bctitle = bcline.substr(0, bcline.find(' '));
  102. index >> intitle;
  103. while (intitle != bctitle)
  104. {
  105. index >> intitle;
  106. }
  107. getline(index, iline);
  108. components = atoi(iline.c_str());
  109. index.close();
  110. result << removeUnder(intitle) << "\n";
  111. iline = iline.substr(3);
  112.  
  113. for (int i = 0; i < components; i++)
  114. {
  115. key = iline.substr(0, 2);
  116. val = parseLine(bcline, key);
  117. iline = iline.append(" ");
  118. iline = iline.substr(iline.find(' ') + 1);
  119. name = iline.substr(0, iline.find(' '));
  120. iline = iline.substr(iline.find(' ') + 1);
  121. result << removeUnder(name) << ": " << val << "\n";
  122. }
  123. }
  124. result << "\n";
  125. }
  126. index.close();
  127. result.close();
  128.  
  129. return 0;
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement