Advertisement
Guest User

Untitled

a guest
Jan 30th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.32 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. void jobOne(){
  8. cout<<"//////Вы выбрали задание 1.сохранение фимилии и имени в строчку//////"<<endl;
  9. string family,name;
  10. cout<<"Введите фамилию"<<endl;
  11. cin>>family;
  12. cout<<"Введите имя"<<endl;
  13. cin>>name;
  14. string FIO = family + ", " + name;
  15. cout<<"Информация сохраненая в строке :"<<FIO<<endl;
  16. }
  17. void jobTwo(){
  18. cout<<"//////Вы выбрали задание 2.Коробка конфет//////"<<endl;
  19. struct CandyBar
  20. {
  21. string title;
  22. double weight;
  23. int numberCalori;
  24. };
  25. CandyBar snack;
  26. cout<<"Введите название конфет"<<endl;
  27. cin>>snack.title;
  28. cout<<"Введите вес коробки"<<endl;
  29. cin>>snack.weight;
  30. cout<<"Введите количество калорий"<<endl;
  31. cin>>snack.numberCalori;
  32. cout<<"Название коробки "<<snack.title<<' '<<"ее вес "<<snack.weight<<" грамм, а количество калорий равно "<<snack.numberCalori<<endl;
  33. }
  34. void jobThree(){
  35. cout<<"//////Вы выбрали задание 3.Массив коробок конфет//////"<<endl;
  36. const int number = 2;
  37. struct CandyBar
  38. {
  39. string title;
  40. double weight;
  41. int numberCalori;
  42. };
  43. CandyBar snack[number];
  44. for(int i = 0;i<number;i++){
  45. cout<<"Введите название конфет"<<endl;
  46. cin>>snack[i].title;
  47. cout<<"Введите вес коробки"<<endl;
  48. cin>>snack[i].weight;
  49. cout<<"Введите количество калорий"<<endl;
  50. cin>>snack[i].numberCalori;
  51. system("cls");
  52. }
  53. for(int i = 0;i<number;i++){
  54. cout<<"Название коробки "<<snack[i].title<<' '<<"ее вес "<<snack[i].weight<<" грамм, а количество калорий равно "<<snack[i].numberCalori<<endl;
  55. cout<<endl;
  56. }
  57. }
  58. void jobFour(){
  59. cout<<"//////Вы выбрали задание 4.Результаты забегов//////"<<endl;
  60. int res[3];
  61. double srRes = 0;
  62. int numberSport = 3;
  63. for(int i =1;i<=numberSport;i++){
  64. cout<<"Введите результаты забега "<<i<<"-ого спортсмена"<<endl;
  65. cin>>res[i -1];
  66. srRes +=res[i -1];
  67. cout<<"Спортсмен пробежал дистанцию 40 метров за "<<res[i - 1]<<" секунд"<<endl;
  68. }
  69. srRes = srRes / (double)(numberSport);
  70. cout<<"Средний результат забега равен "<<srRes<<" секунд"<<endl;
  71. }
  72.  
  73. int main()
  74. {
  75. setlocale(LC_ALL, "Russian");
  76. cout<<"Вся информация вводится только на английском языке!!!"<<endl;
  77. cout<<"1.Сохранение фимилии и имени в строчку"<<endl;
  78. cout<<"2.Коробка конфет"<<endl;
  79. cout<<"3.Массив коробок конфет"<<endl;
  80. cout<<"4.Результаты забегов"<<endl;
  81. cout<<"Введите номер интересуещего вас задания:"<<endl;
  82. int number;
  83. cin>>number;
  84. system("cls");
  85. if (number == 1)
  86. #include "stdafx.h"
  87. #include <iostream>
  88. #include <string>
  89.  
  90. using namespace std;
  91.  
  92. void jobOne(){
  93. cout<<"//////¬˚ ‚˚·‡ÎË Á‡‰‡ÌËÂ Ó ÔÂÓ·‡ÁÓ‚‡ÌË ‚‡Î˛Ú˚//////"<<endl;
  94. cout<<"¬‚‰ËÚ ÍÓ΢ÂÒÚ‚Ó ‰ÓÎÓÓ‚, ÍÓÚÓÓ ·Û‰ÂÚ ÔÂÓ·‡ÁÓ‚‡Ì ‚ Û·ÎË"<<endl;
  95. double numberDolars;
  96. cin>>numberDolars;
  97. cout<<" Ó΢ÂÒÚ‚Ó Û·ÎÂÈ ‡‚ÌÓ = "<<numberDolars * 52.8150417<<endl;
  98. }
  99. void jobTwo(){
  100. cout<<"//////¬˚ ‚˚·‡ÎË Á‡‰‡ÌËÂ Ó ÔÓˆÂÌÚ ̇ÒÂÎÂÌˡ –ÓÒÒËË ‚ ÏËÂ//////"<<endl;
  101. unsigned long long populationWorld = 7212812960;
  102. unsigned long long populationRussian = 142725201;
  103. double oneProcent= double (populationWorld) / 100;
  104. double procentRussian = populationRussian / oneProcent;
  105. cout<<"œÓˆÂÌÚ ÛÒÒÍÓ„Ó Ì‡ÒÂÎÂÌˡ ËÁ ̇ÒÂÎÂÌˡ ÏË‡ ‡‚ÂÌ"<<' '<<procentRussian<<' '<<'%'<<endl;
  106. }
  107. void jobThree(){
  108. cout<<"//////¬˚ ‚˚·‡ÎË Á‡‰‡ÌËÂ Ó ÔÓ‰Ò˜ÂÚ ÍÓ΢ÂÒÚ‚‡ ·ÛÍ‚ ‚ ‘»Œ//////"<<endl;
  109. string family,name,patronomic;
  110. cout<<"¬‚‰ËÚ هÏËÎ˲"<<endl;
  111. cin>>family;
  112. cout<<"¬‚‰ËÚ ËÏˇ"<<endl;
  113. cin>>name;
  114. cout<<"¬‚‰ËÚ ÓÚ˜ÂÒÚ‚Ó"<<endl;
  115. cin>>patronomic;
  116. system("cls");
  117. cout<<" Ó΢ÂÒÚ‚Ó ·ÛÍ‚ ‚:"<<endl<<"1.Ù‡ÏËÎËË="<<family.length()<<endl<<"2.ËÏÂÌË="<<name.length()<<endl<<"3.ÓÚ˜ÂÒÚ‚Â="<<patronomic.length()<<endl;
  118. }
  119. int visYear(int year){
  120. int difference= 2014 - year;
  121. int vesYear = 0;
  122. for (int i=0 ;i<difference;i++ ){
  123. if (((year + i) %400 == 0) && ((year + i) %100 == 0) && ((year + i) %4 == 0))
  124. vesYear++;
  125. else
  126. if (((year + i) %4 == 0) && ((year + i) %100) != 0)
  127. vesYear++;
  128. }
  129. return vesYear;
  130. }
  131. void jobFour(){
  132. int year;
  133. cout<<"//////¬˚ ‚˚·‡ÎË Á‡‰‡ÌËÂ Ó ÍÓ΢ÂÒÚ‚Â ‚ËÒÓÍÓÒÚÌ˚ı „Ó‰Ó‚ ̇ ÔÓÏÂÊÛÚÂ//////"<<endl;
  134. cout<<"“ÂÍÛ˘ÂÈ „Ó‰ 2014"<<endl;
  135. cout<<"¬‚‰ËÚ „Ó‰ ÓÚ ÍÓÚÓÓ„Ó ·Û‰ÂÏ Ò˜ËÚ‡Ú¸"<<endl;
  136. cin>>year;
  137. cout<<" Ó΢ÂÚÒ‚Ó ‚ËÒÓÍÓÒÚÌ˚ı „Ó‰Ó‚="<<visYear(year)<<endl;
  138. }
  139. void jobFive(){
  140. cout<<"//////¬˚ ‚˚·‡ÎË Á‡‰‡ÌËÂ Ó ÓÚÓ·‡ÊÂÌË ‚ÓÁ‡ÒÚ‡ ‚ ‰Ìˇı Ë ÏÂÒˇˆ‡ı//////"<<endl;
  141. struct data
  142. {
  143. int year;
  144. int month;
  145. int day;
  146. };
  147. data current,birthday;
  148. current.year = 2014;current.month = 1;current.day = 1;
  149. cout<<"¬‚‰ËÚ „Ó‰ ÓʉÂÌˡ"<<endl;
  150. cin>>birthday.year;
  151. cout<<"¬‚‰ËÚ ÏÂÒˇˆ ÓʉÂÌˡ"<<endl;
  152. cin>>birthday.month;
  153. cout<<"¬‚‰ËÚ ‰Â̸ ÓʉÂÌˡ"<<endl;
  154. cin>>birthday.day;
  155. cout<<" Ó΢ÂÒÚ‚Ó ÏÂÒˇˆÂ‚ ‡‚ÌÓ "<<((current.year - birthday.year) * 12) - birthday.month <<endl;
  156. cout<<endl;
  157. int numberVisYear = visYear(birthday.year) ;
  158. unsigned long long int numberDay;
  159. numberDay = ((current.year - birthday.year) - (1 + numberVisYear ) ) * 365 + (numberVisYear * 366);
  160. int difference;
  161. if (birthday.month == 1)
  162. difference = 31 - birthday.day;
  163. if (birthday.month == 2)
  164. difference = 28 - birthday.day;
  165. if (birthday.month == 3)
  166. difference = 31 - birthday.day;
  167. if (birthday.month == 4)
  168. difference = 30 - birthday.day;
  169. if (birthday.month == 5)
  170. difference = 31 - birthday.day;
  171. if (birthday.month == 6)
  172. difference = 30 - birthday.day;
  173. if (birthday.month == 7)
  174. difference = 31 - birthday.day;
  175. if (birthday.month == 8)
  176. difference = 31 - birthday.day;
  177. if (birthday.month == 9)
  178. difference = 30 - birthday.day;
  179. if (birthday.month == 10)
  180. difference = 31 - birthday.day;
  181. if (birthday.month == 11)
  182. difference = 30 - birthday.day;
  183. if (birthday.month == 12)
  184. difference = 31 - birthday.day;
  185. numberDay+=difference;
  186. for (int i = 1 ;i< (12 - current.month);i++ ){
  187. if (i == 1)
  188. numberDay += 31;
  189. if (i == 2)
  190. numberDay += 28;
  191. if (i == 3)
  192. numberDay += 31 ;
  193. if (i == 4)
  194. numberDay += 30;
  195. if (i == 5)
  196. numberDay += 31;
  197. if (i == 6)
  198. numberDay += 30;
  199. if (i == 7)
  200. numberDay += 31;
  201. if (i == 8)
  202. numberDay += 31;
  203. if (i == 9)
  204. numberDay += 30 ;
  205. if (i == 10)
  206. numberDay += 31;
  207. if (i == 11)
  208. numberDay += 30;
  209. if (i == 12)
  210. numberDay += 31;
  211. }
  212. cout<<" Ó΢ÂÒÚ‚Ó ‰ÌÂÈ ‡‚ÌÓ "<<numberDay<<endl;
  213. }
  214. void jobSix(){
  215. cout<<"//////¬˚ ‚˚·‡ÎË Á‡‰‡ÌËÂ Ó ÔÂÓ·‡ÁÓ‚‡ÌË ÒÂÍÛ̉ ‚ ÏËÌÛÚ˚, ˜‡Ò˚, ÒÛÚÍË//////"<<endl;
  216. cout<<"¬‚‰ËÚ ÍÓ΢ÂÒÚ‚Ó ÒÂÍÛ̉"<<endl;
  217. int sec;
  218. cin>>sec;
  219. double inMinuts,inHours,inDay;
  220. inMinuts = double(sec) / 60;
  221. inHours = inMinuts / 60;
  222. inDay = inHours/24;
  223. cout<<" Ó΢ÂcÚ‚Ó "<<sec<<" ÒÂÍÛ̉ ‚:"<<endl<<"1.ÏËÌÛÚ‡ı ="<<inMinuts<<endl<<"2.˜‡Ò‡ı ="<<inHours<<endl<<"3.‰Ìˇı ="<<inDay<<endl;
  224. }
  225.  
  226. int main(){
  227. setlocale(LC_ALL, "Russian");
  228. cout<<"¬Òˇ ËÌÙÓχˆËˇ ‚‚Ó‰ËÚÒˇ ÚÓθÍÓ Ì‡ ‡Ì„ÎËÈÒÍÓÏ ˇÁ˚ÍÂ!!!"<<endl;
  229. cout<<"1.œÂÓ·‡ÁÓ‚‡ÌË ‰ÓÎÎÓÓ‚ ‚ Û·ÎË"<<endl;
  230. cout<<"2.œÓˆÂÌÚ Ì‡ÒÂÎÂÌˡ –ÓÒÒËË ËÁ ̇ÒÂÎÂÌˡ ÒÚ‡Ì˚"<<endl;
  231. cout<<"3.œÓ‰Ò˜ÂÚ ÍÓ΢ÂÒÚ‚ ·ÛÍ‚ ‚ ‘»Œ"<<endl;
  232. cout<<"4. Ó΢ÂÚÒ‚Ó ‚ËÒÓÍÓÒÚÌ˚ı „Ó‰Ó‚"<<endl;
  233. cout<<"5.ŒÚÓ·‡ÊÂÌˡ ‚ÓÁ‡ÒÚ‡ ‚ ‰Ìˇı Ë ÏÂÒˇˆ‡ı"<<endl;
  234. cout<<"6.œÂÓ·‡ÁÓ‚‡ÌË ÒÂÍÛ̉ ‚ ÏËÌÛÚ˚, ˜‡Ò˚, ÒÛÚÍË"<<endl;
  235. cout<<"¬‚‰ËÚ ÌÓÏÂ ËÌÚÂÂÒÛÂ˘Â„Ó ‚‡Ò Á‡‰‡Ìˡ"<<endl;
  236. int number;
  237. while (number !=0){
  238. cin>>number;
  239. system("cls");
  240. if (number ==1 )
  241. jobOne();
  242. if (number ==2 )
  243. jobTwo();
  244. if (number ==3 )
  245. jobThree();
  246. if (number ==4 )
  247. jobFour();
  248. if (number ==5 )
  249. jobFive();
  250. if (number ==6 )
  251. jobSix();
  252. }
  253. system("pause");
  254. return 0;
  255. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement