Recent Changes - Search:

Oktatás

* Programozás 1
  + feladatsor
  + GitHub oldal

* Szkriptnyelvek
  + feladatsor
  + quick link

Teaching

* Programming 1 (BI)
  ◇ exercises
  ◇ quick link

teaching assets


Félévek

* 2024/25/2
* archívum


Linkek

* kalendárium
   - munkaszüneti napok '20
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C++
* C#
* Clojure
* D lang.
* Java
* Nim
* Scala


[ edit | logout ]
[ sandbox | passwd ]

Fill up a string with leading 0s

See also std.string.

There's no zfill() in D, but we can do it easily 🎯

(1) zfill()
def main():
    s = "7"
    print(s.zfill(3))  # "007"

    s = "12345"
    print(s.zfill(2))  # "12345"
import std.stdio;
import std.string;

string zfill(const string s, const int width)
{
    return s.rightJustify(width, '0');
}

void main()
{
    string s = "7";
    writeln(s.zfill(3)); // "007"

    s = "12345";
    writeln(s.zfill(2)); // "12345"
}
Cloud City

  

Blogjaim, hobbi projektjeim

* The Ubuntu Incident
* Python Adventures
* @GitHub
* heroku
* extra
* haladó Python
* YouTube listák


Debrecen | la France


[ edit ]

Edit - History - Print *** Report - Recent Changes - Search
Page last modified on 2025 July 02, 16:52