Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <cstdlib>
  5. #include <iostream>
  6. #include <fstream>
  7. #include <conio.h>
  8. #include <windows.h>
  9. #include <string.h>
  10. using namespace std;
  11.  
  12. int main()
  13. {
  14. //SetConsoleCP(1251);
  15. //SetConsoleOutputCP(1251);
  16. setlocale(LC_ALL,"rus");
  17.  
  18.  
  19. ifstream file("C:\\Users\\kbstudentint\\Desktop\\О сотрудниках.txt");//путь к файлу
  20. char open_file[400];
  21. int z[6],z1[6],z3[6];
  22. int index = -1;
  23. int buf, buf1, buf2,sum,sum1,sum2;
  24. do
  25. {
  26. index++;
  27. if (index == 4 ) //Проверка номера строки
  28. {
  29. z[0] = atoi(open_file);
  30.  
  31. }
  32. if (index == 5)
  33. {
  34. z[1] = atoi(open_file);
  35.  
  36. }
  37. if (index == 6)
  38. {
  39. z[2] = atoi(open_file);
  40.  
  41. }
  42. if (index == 7)
  43. {
  44. z[3] = atoi(open_file);
  45.  
  46. }
  47. if (index == 8)
  48. {
  49. z[4] = atoi(open_file);
  50.  
  51. }
  52. if (index == 9)
  53. {
  54. z[5] = atoi(open_file);
  55.  
  56. }
  57.  
  58.  
  59.  
  60. if (index == 13)
  61. {
  62. z1[0] = atoi(open_file);
  63.  
  64. }
  65. if (index == 14)
  66. {
  67. z1[1] = atoi(open_file);
  68.  
  69. }
  70. if (index == 15)
  71. {
  72. z1[2] = atoi(open_file);
  73.  
  74. }
  75. if (index == 16)
  76. {
  77. z1[3] = atoi(open_file);
  78.  
  79. }
  80. if (index == 17)
  81. {
  82. z1[4] = atoi(open_file);
  83.  
  84. }
  85. if (index == 18)
  86. {
  87. z1[5] = atoi(open_file);
  88.  
  89. }
  90.  
  91.  
  92. if (index == 22)
  93. {
  94. z3[0] = atoi(open_file);
  95.  
  96. }
  97. if (index == 23)
  98. {
  99. z3[1] = atoi(open_file);
  100.  
  101. }
  102. if (index == 24)
  103. {
  104. z3[2] = atoi(open_file);
  105.  
  106. }
  107. if (index == 25)
  108. {
  109. z3[3] = atoi(open_file);
  110.  
  111. }
  112. if (index == 26)
  113. {
  114. z3[4] = atoi(open_file);
  115.  
  116. }
  117. if (index == 27)
  118. {
  119. z3[5] = atoi(open_file);
  120.  
  121. }
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128. file.getline(open_file, 400);//считывает одну строку файла
  129. } while (!file.eof());
  130. /**/
  131.  
  132. _asm{ xor ebx,ebx}
  133. for (int i = 0; i < 6; i++) //находим сумму зарплат
  134. {
  135. buf = z[i];
  136. _asm
  137. {
  138. xor eax, eax
  139. mov eax,buf
  140. add ebx,eax
  141. mov sum,ebx
  142. }
  143. }
  144. _asm{ xor ebx, ebx}
  145. for (int i = 0; i < 6; i++)
  146. {
  147. buf1 = z1[i];
  148. _asm
  149. {
  150. xor eax, eax
  151. mov eax, buf1
  152. add ebx, eax
  153. mov sum1, ebx
  154. }
  155. }
  156. _asm{ xor ebx, ebx}
  157. for (int i = 0; i < 6; i++)
  158. {
  159. buf2 = z3[i];
  160. _asm
  161. {
  162. xor eax, eax
  163. mov eax, buf2
  164. add ebx, eax
  165. mov sum2, ebx
  166. }
  167. }
  168. double sums = sum, sra, n = 6.0, sums1 = sum1,sums2 = sum2, sra1, sra2;
  169. //делим и находим СРА
  170. _asm
  171. {
  172. xor eax,eax
  173. xor ebx,ebx
  174. FINIT
  175. fld sums
  176. fdiv n
  177. fstp sra
  178. }
  179. _asm
  180. {
  181. xor eax, eax
  182. xor ebx, ebx
  183. FINIT
  184. fld sums1
  185. fdiv n
  186. fstp sra1
  187. }
  188. _asm
  189. {
  190. xor eax, eax
  191. xor ebx, ebx
  192. FINIT
  193. fld sums2
  194. fdiv n
  195. fstp sra2
  196. }
  197. cout << "1 Сотрудник: " << endl;
  198. cout << "Зарплаты:" << endl;
  199. for (int i = 0; i < 6; i++)
  200. {
  201. cout << z[i] << endl;
  202. }
  203. cout << "Средняя зарплата " << sra<<endl;
  204. cout <<endl<< "2 Сотрудник: " << endl;
  205. cout << "Зарплаты:" << endl;
  206. for (int i = 0; i < 6; i++)
  207. {
  208. cout << z1[i] << endl;
  209. }
  210. cout << "Средняя зарплата " << sra1 << endl;;
  211. cout <<endl<< "3 Сотрудник: " << endl;
  212. cout << "Зарплаты:" << endl;
  213. for (int i = 0; i < 6; i++)
  214. {
  215. cout << z3[i] << endl;
  216. }
  217. cout << "Средняя зарплата " << sra2;
  218. system("pause");
  219. return 0;
  220. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement