首页 > 解决方案 > 如何在序言中打印空格

问题描述

我需要使用 write() 打印到流中,但我不知道如何打印“空白”空格。例如我想写

       10    3     
   5     3    6

write('10 3') 只写 10 3 (删除多余的空格),我想打印前导空格。有人知道我该怎么做吗?

编辑:我想打印一个包含一些空格和一些数字的字符矩阵。程序的最终目标就是这样。但如果我这样做

?- write(' '), write(' '), write('3')
3
true

我想实现

   3

标签: prolog

解决方案


Please edit your question with a complete program we can run, and the output you get, and the output you would like to get.

This seems to work for me on SWI-Prolog 7.6.4:

?- write('10 3'), nl, write('    10    3    '), write('7'), nl.
10 3
    10    3    7
true.

推荐阅读