{"id":14604,"date":"2024-04-17T21:00:37","date_gmt":"2024-04-17T18:00:37","guid":{"rendered":"https:\/\/elzero.org\/?p=14604"},"modified":"2024-04-14T21:59:44","modified_gmt":"2024-04-14T18:59:44","slug":"implement-functions-with-cpp-zfill","status":"publish","type":"post","link":"https:\/\/elzero.org\/old\/implement-functions-with-cpp-zfill\/","title":{"rendered":"zFill"},"content":{"rendered":"<h3>\u0645\u062d\u062a\u0648\u0649 \u0627\u0644\u062f\u0631\u0633<\/h3>\r\n\r\n<script type=\"text\/plain\" class=\"language-c\">\r\n#include <iostream>\r\nusing namespace std;\r\n\r\n\/\/ zFill\r\n\r\n\/\/ 00150\r\n\/\/ 06500\r\n\/\/ 11350\r\n\r\n\/\/ Example String => \"6500\" => Length -> 4\r\n\/\/ Example Width => 7\r\n\r\nstring zFill(string st, int width, string fill = \"0\")\r\n{\r\n  int len = st.length(); \/\/ 4\r\n  if (len < width)\r\n  {\r\n    for (int i = 0; i < width - len; i++)\r\n    {\r\n      \/\/ 0006500\r\n      st = fill + st;\r\n    }\r\n  }\r\n  return st;\r\n}\r\n\r\nint main()\r\n{\r\n  cout << zFill(\"150\", 7, \"@\") << endl;\r\n  cout << zFill(\"6550\", 7, \"@\") << endl;\r\n  cout << zFill(\"11650\", 7, \"@\") << endl;\r\n  cout << zFill(\"155650\", 7, \"@\") << endl;\r\n  return 0;\r\n}\r\n\r\n<\/script>","protected":false},"excerpt":{"rendered":"<p>\u0645\u062d\u062a\u0648\u0649 \u0627\u0644\u062f\u0631\u0633<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1454],"tags":[],"class_list":["post-14604","post","type-post","status-publish","format-standard","hentry","category-implement-functions-with-cpp"],"_links":{"self":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/14604","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/comments?post=14604"}],"version-history":[{"count":2,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/14604\/revisions"}],"predecessor-version":[{"id":14606,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/14604\/revisions\/14606"}],"wp:attachment":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/media?parent=14604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/categories?post=14604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/tags?post=14604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}