fork(4) download
  1. //#include <iostream>
  2. //#include <vector>
  3. //#include <string>
  4. //#include <sstream>
  5. //#include <cstdint>
  6. //#include <algorithm>
  7. ///**
  8. //EULER #43
  9. // 0123456789
  10. //The number, 1406357289, is a 0 to 9 pandigital number because it is
  11. //made up of each of the digits 0 to 9 in some order, but it also has
  12. //a rather interesting sub-string divisibility property.
  13. //
  14. //Let d1 be the 1st digit, d2 be the 2nd digit, and so on. In this way, we note the following:
  15. //
  16. //d2d3d4=406 is divisible by 2
  17. //d3d4d5=063 is divisible by 3
  18. //d4d5d6=635 is divisible by 5
  19. //d5d6d7=357 is divisible by 7
  20. //d6d7d8=572 is divisible by 11
  21. //d7d8d9=728 is divisible by 13
  22. //d8d9d10=289 is divisible by 17
  23. //Find the sum of all 0 to 9 pandigital numbers with this property.
  24. //*/
  25. //
  26. //bool divisable(int num, int b)
  27. //{
  28. // int a[] = {1,2,3,5,7,11,13,17};
  29. // return !(num % a[b]);
  30. //}
  31. //
  32. //bool stripInvalid(const std::string& s)
  33. //{
  34. // if(s[0] == '0' || s[5] != '5' || (s[3] % 2 != 0))
  35. // return false;
  36. //
  37. // for(int i = 0; i <= 9; ++i)
  38. // {
  39. // if(s.find( i + '0') == std::string::npos)
  40. // {
  41. // return false;
  42. // }
  43. // }
  44. // return true;
  45. //}
  46. //
  47. //uint64_t checkNum(const std::string& s)
  48. //{
  49. // std::stringstream ss;
  50. // uint64_t t = 0;
  51. // for(int i = 0; i < 8; ++i)
  52. // {
  53. // t = 0;
  54. // ss.clear();
  55. // std::string st = s.substr(i, 3);
  56. // ss << st;
  57. // ss >> t;
  58. // if(!divisable(t, i))
  59. // {
  60. // return 0;
  61. // }
  62. // }
  63. // ss.clear();
  64. // ss << s;
  65. // ss >> t;
  66. // return t;
  67. //}
  68. //
  69. //bool checkDig(uint64_t t)
  70. //{
  71. // uint64_t t_ = t;
  72. // std::vector<int> v;
  73. // for(int i = 0; i < 8; ++i)
  74. // {
  75. // /*v.push_back(t%1000);
  76. // t/=1000;*/
  77. // if(!divisable(t_%1000, i))
  78. // {
  79. // return false;
  80. // }
  81. // }
  82. // return true;
  83. //
  84. //}
  85. //std::vector<std::string> permute(std::string s)
  86. //{
  87. // std::string orig = s;
  88. // std::vector<std::string> v;
  89. // // v.push_back(s);
  90. // int len = s.length();
  91. // int i = len - 4;
  92. // bool done = false;
  93. // int digits = 0;
  94. //
  95. // while(digits < len)
  96. // {
  97. // while(i > 0)//12345
  98. // {
  99. // int j = i+1;
  100. // while(!done)
  101. // {
  102. // if(j < len - 1)
  103. // {
  104. // std::swap(s[j], s[j+1]);
  105. // v.push_back(s);
  106. // ++j;
  107. // }
  108. // else
  109. // j = i+1;
  110. // if(s == orig)
  111. // done = true;
  112. // }
  113. // std::swap(s[i], s[digits+2]);
  114. //
  115. // // if(s[1] == orig[len - 1]) i = len - 4;
  116. // // else
  117. // --i;
  118. //
  119. // orig = s;
  120. // done = false;
  121. // }
  122. // // std::swap(s[0], s[1]);
  123. // ++digits;
  124. // i = len - 4;
  125. // }
  126. // return v;
  127. //}
  128. //
  129. //int main()
  130. //{
  131. // //std::string s = "1406357280";
  132. // std::vector<int> v;
  133. // //std::stringstream ss;
  134. // uint64_t sum = 0,
  135. // t = 0;
  136. // /*std::cout << s[3] % 2 << std::endl;
  137. // ss << s;
  138. // ss >> t;*/
  139. // std::vector<std::string> vs = permute("12345");
  140. // for(int i = 0; i < vs.size(); ++i)//while(s != "4200000000")
  141. // {
  142. // if(stripInvalid(vs[i]))
  143. // {
  144. // if((t = checkNum(vs[i])) != 0)
  145. // {
  146. // v.push_back(t);
  147. // std::cout << t << std::endl;
  148. // }
  149. // //std::cout<<s<<std::endl;
  150. // }
  151. // /* ss << s;
  152. // ss >> t;
  153. // ++t;
  154. // s = std::to_string(t);*/
  155. // }
  156. //
  157. // for(auto& i : v)
  158. // sum += i;
  159. // std::cout << "sum= " << sum << std::endl;
  160. // std::cin>>t;
  161. //}
  162. ////int main()
  163. ////{
  164. //// uint64_t sum = 0;
  165. ////
  166. //// std::string s = "1430950000";
  167. //// std::vector<int> v;
  168. //// std::stringstream ss;
  169. //// uint64_t t = 0;
  170. //// bool good = true;
  171. //// while(s != "4200000000")
  172. //// {
  173. //// for(int i = 0; i <= 9; ++i)
  174. //// {
  175. //// if(s[0] != '0' || s.find( i + '0') == std::string::npos)
  176. //// {
  177. //// good = false;
  178. //// break;
  179. //// }
  180. //// }
  181. ////
  182. //// if(good)
  183. //// {
  184. ////
  185. //// // int arr[8];
  186. ////
  187. //// for(int i = 0; i < 9; ++i)
  188. //// {
  189. //// std::string st = s.substr(i, 3);
  190. //// ss << st;
  191. //// ss >> t;
  192. //// if(t%(i+1) != 0)
  193. //// {
  194. //// good = false;
  195. //// break;
  196. //// }
  197. //// }
  198. ////
  199. //// if(good)
  200. //// {
  201. //// ss << s;
  202. //// ss >> t;
  203. //// sum += t;
  204. //// std::cout<<s<<std::endl;
  205. //// }
  206. //// }
  207. //// ss << s;
  208. //// ss >> t;
  209. //// ++t;
  210. //// s = std::to_string(t);
  211. //// good = true;
  212. //// //std::cout<<s<<std::endl;
  213. //// }
  214. ////}
  215. #include<iostream>
  216. #include<array>
  217. #include<string>
  218. using namespace std;
  219.  
  220. void print_gene_table2(array< array<string,6>,22 >);
  221.  
  222. int main()
  223. {
  224.  
  225. // EXCEPTION: too many initializers for ‘std::array<std::array<std::basic_string<char>, 6ul>, 22ul>’
  226.  
  227. array< array<string,6>,22 > gene_table1 =
  228. {{// extra brace needed here
  229. {"UUU","UUC"}, // Phe
  230. {"UUA","UUG","CUU","CUC","CUA","CUG"}, // Leu
  231. {"UCU","UCC","UCA","UCG","AGU","AGC"}, // Ser
  232. {"UAU","UAC"}, // Tyr
  233. {"UAA","UAG","UGA"}, // STO
  234. {"UGU","UGC"}, // Cys
  235. {"UGG"}, // Trp
  236. {"CCU","CCC","CCA","CCG"}, // Pro
  237. {"CAU","CAC"}, // His
  238. {"CAA","CAG"}, // Gln
  239. {"CGU","CGC","CGA","CGG"}, // Arg
  240. {"AUU","AUC","AUA"}, // Ile
  241. {"AUG"}, // STA or Met
  242. {"ACU","ACC","ACA","ACG"}, // Thr
  243. {"AAU","AAC"}, // Asn
  244. {"AAA","AAG"}, // Lys
  245. {"AGA","AGG"}, // Arg
  246. {"GUU","GUC","GUA","GUG"}, // Val
  247. {"GCU","GCC","GCA","GCG"}, // Ala
  248. {"GAU","GAC"}, // Asp
  249. {"GAA","GAG"}, // Glu
  250. {"GGU","GGC","GGA","GGG"} // Gly
  251. }};//and here
  252.  
  253. print_gene_table2(gene_table1);
  254.  
  255. return 0;
  256. }
  257.  
  258. void print_gene_table2(array< array<string,6>,22 > gene_table1)
  259. {
  260. for(unsigned i = 0;i < gene_table1.size();i++)//you were mising a condition here
  261. {//brace here
  262. for(unsigned j = 0;j < gene_table1[i].size();j++)
  263. {
  264. cout << gene_table1[i][j] << " ";
  265. }
  266. cout<<endl;
  267. }//and here
  268. }
Success #stdin #stdout 0s 3036KB
stdin
Standard input is empty
stdout
UUU  UUC          
UUA  UUG  CUU  CUC  CUA  CUG  
UCU  UCC  UCA  UCG  AGU  AGC  
UAU  UAC          
UAA  UAG  UGA        
UGU  UGC          
UGG            
CCU  CCC  CCA  CCG      
CAU  CAC          
CAA  CAG          
CGU  CGC  CGA  CGG      
AUU  AUC  AUA        
AUG            
ACU  ACC  ACA  ACG      
AAU  AAC          
AAA  AAG          
AGA  AGG          
GUU  GUC  GUA  GUG      
GCU  GCC  GCA  GCG      
GAU  GAC          
GAA  GAG          
GGU  GGC  GGA  GGG