DilyaraL

отчет1

May 23rd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.06 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. void main()
  4. {
  5. char s[7] = "+6.e-7";
  6. bool b = true;
  7. int q = 0;
  8. int i;
  9. for (i = 0; i < 6 && b; i++)
  10. {
  11. switch (q)
  12. {
  13. case 0: if (s[i] == '+' || s[i] == '-')
  14. q = 1;
  15. else b = false;
  16. break;
  17. case 1:
  18. if (s[i] <= '9'&& s[i] >= '0')
  19. q = 2;
  20. else b = false;
  21. break;
  22. case 2:
  23. if (s[i] <= '9'&& s[i] >= '0')
  24. q = 2;
  25. else
  26. {
  27. if (s[i] <= '.')
  28. q = 3;
  29. else b = false;
  30. }
  31. break;
  32. case 3:
  33. if (s[i] <= '9'&& s[i] >= '0')
  34. q = 4;
  35. else b = false;
  36. break;
  37. case 4:
  38. if (s[i] <= '9'&& s[i] >= '0')
  39. q = 4;
  40. else
  41. {
  42. if (s[i] == 'E' || s[i] == 'e')
  43. q = 5;
  44. else b = false;
  45. }
  46. break;
  47. case 5: if (s[i] == '+' || s[i] == '-')
  48. q = 6;
  49. else b = false;
  50. break;
  51. case 6:
  52. if (s[i] <= '9'&& s[i] >= '0')
  53. q = 7;
  54. else b = false;
  55. break;
  56. case 7: if (s[i] <= '9'&& s[i] >= '0')
  57. q = 7;
  58. else
  59. b = false;
  60. break;
  61. }
  62. }
  63.  
  64. if (b && q == 7)
  65. cout << "Correctly"<<endl;
  66. else cout << "Incorrectly" << endl;
  67. system("pause");
  68. }
  69.  
  70.  
  71. #include <iostream>
  72. using namespace std;
  73.  
  74. void main()
  75. {
  76. setlocale(LC_ALL, "Russian");
  77. int x[8] = { 8,7,6,5,4,3,2,1 };
  78. bool f1 = true;
  79. bool f2 = true;
  80. for (int i = 0; i < 7&&f1; i++)
  81. {
  82. if (x[i] >= x[i + 1]) f1 = false;
  83. }
  84.  
  85. for (int i = 0; i < 7 && f2; i++)
  86. {
  87. if (x[i] <= x[i + 1]) f2 = false;
  88. }
  89. if (f1) cout << "упорядочен по возрастанию "<<endl;
  90. else if (!f2)cout<< "неупорядочен по возрастанию и неупорядочен по убыванию ";
  91. else cout << "упорядочен по убыванию ";
  92. system("pause");
  93. }
  94.  
  95.  
  96. #include <iostream>
  97. #include <fstream>
  98. #include <iomanip>
  99. #include <string>
  100. using namespace std;
  101.  
  102. const int str = 12;
  103. const int st = 4;
  104. const int len = 44;
  105. const int n = 5;
  106. const int m = 4;
  107.  
  108. void star1(int len,ofstream &f)
  109. {
  110. for (int i = 0; i < len; i++)
  111. f << '*';
  112. f << endl;
  113. }
  114. void star2(ifstream &f, ofstream &f2, int n1, int n2, int n3)// n1,n2- length of columns, n3 - quantity of columns
  115. {
  116. string s;
  117. f >> s;
  118. f2 << '*' << setw(n1) << s << "*";
  119. for (int i = 0; i < n3; i++)
  120. {
  121. f >> s;
  122. f2 << setw(n2) << s << " *";
  123. }
  124. f2 << endl;
  125. }
  126. int main()
  127. {
  128. ifstream in("Text.txt");
  129. ofstream out("Text1.txt");
  130. int **a = new int *[m];
  131. for (int i = 0; i < m; i++)
  132. a[i] = new int[n];
  133.  
  134. for (int i = 0; i < m; i++)
  135. for (int j = 0; j < n; j++)
  136. in >> a[i][j];
  137. out << setw(26) << "Selling " << endl;
  138. star1(len,out);
  139. star2(in,out, str, st, n);
  140. star1(len, out);
  141. string s;
  142. for (int i = 0; i < m; i++)
  143. {
  144. in >> s;
  145. out << '*' <<std::left<< setw(str) << s << '*';
  146. for (int j = 0; j < n; j++)
  147. {
  148. out << setw(st) << std::right<< a[i][j] << " *";
  149. }
  150. out << endl;
  151. star1(len, out);
  152. }
  153.  
  154. int sum[n];
  155. for (int i = 0; i < n; i++)
  156. sum[i] = 0;
  157.  
  158. for (int i = 0; i < n; i++)
  159. for (int j = 0; j < m; j++)
  160. sum[i] = sum[i] + a[j][i];
  161.  
  162. s = "total";
  163. out << '*' << setw(str) << std::left << s << '*';
  164. for (int j = 0; j < n; j++)
  165. {
  166. out << setw(st) << std::right << sum[j] << " *";
  167. }
  168. out << endl;
  169. star1(len, out);
  170.  
  171. system("pause");
  172.  
  173. return 0;
  174. }
  175.  
  176. #include <iostream>
  177. #include <math.h>
  178. using namespace std;
  179.  
  180. void print(int n)
  181. {
  182. if (n > 0)
  183. {
  184. print(n - 1);
  185. cout << n << ' ';
  186. }
  187. }
  188.  
  189. int main()
  190. {
  191. int m;
  192. cin >> m;
  193. print(m);
  194. system("pause");
  195. return 0;
  196. }
  197.  
  198. #include <iostream>
  199. #include <fstream>
  200. #include <string>
  201. #include <stdio.h>
  202. using namespace std;
  203.  
  204. int main()
  205. {
  206. string s;
  207. getline(cin, s);
  208. int n = s.length();
  209. int k = 0; int n1, n2=-1;
  210. bool f=true;
  211. for (int i = 1; i < n - 1; i++)
  212. {
  213. if (s[i-1] == ' ')
  214. {
  215. n1 = i;
  216. }
  217. if (s[i + 1] == ' ')
  218. {
  219. n2 = i;
  220. }
  221. if (s[i] == ' ') { f = true; n1 = 0; n2 = 0; }
  222. if (n1*n2>0)
  223. {
  224. for (int j = 0; j < (n2 - n1 + 1) / 2 && f; j++)
  225. {
  226. if (s[n1 + j] != s[n2 - j]) f = false;
  227. }
  228. if (f) k++;
  229. }
  230.  
  231.  
  232. }
  233. cout << k;
  234. system("pause");
  235. return 0;
  236. }
Add Comment
Please, Sign In to add comment