简体   繁体   English

如何在纯 C 中打印压缩点,以便将它们视为单个数学图形(线、正方形、矩形等)?

[英]How to print compacted points in pure C, so they can be seen as a single mathematical figure (line, square, rectangle, etc.)?

In the following code I'm printing 10 points in a straight line.在下面的代码中,我在一条直线上打印 10 个点。 How can I make these points be compacted so that someone can see all of them as an almost continuous line without, using any graphical library?我怎样才能使这些点被压缩,以便有人可以在不使用任何图形库的情况下将所有这些点视为一条几乎连续的线?

#include <stdio.h>
int main()
{
    for (int i=0; i<10; i++)
        printf("%c", '.');
    return 0;
}
          ,
         _o_
    ._ ,'   `o'
----(_)      :       ^aNT
    '  `.   .o
         ~o~  `
          '

A "picture" is worth a thousand words.一张图片胜过千言万语。

How can I make these points be compacted so that someone can see all of them as an almost continuous line without, using any graphical library?我怎样才能使这些点被压缩,以便有人可以在不使用任何图形库的情况下将所有这些点视为一条几乎连续的线?

You can´t do that by using points.你不能通过使用积分来做到这一点。 You need to print fe subsequent _ characters to print a line, fe:您需要打印 fe 后续_字符来打印一行,fe:

printf("_______________");

If you want to use vertical lines, use the |如果要使用垂直线,请使用| character in subsequent calls to printf:后续调用 printf 中的字符:

printf("|\n");
printf("|\n");
printf("|\n");
printf("|\n");

or just要不就

printf("|\n|\n|\n|\n|\n");

One example:一个例子:

#include <stdio.h>

int main(void)
{    
   printf("___________________________\n");
   printf("|    ````        ````     |\n");
   printf("|      X         X        |\n");
   printf("|           O             |\n");
   printf("|                         |\n");
   printf("|   |________________|    |\n");
   printf("|         |____|          |\n");
   printf("|_________________________|\n");
}

Output: Output:

___________________________       
|    ````       ````      |              
|      X         X        |            
|           O             |      
|                         |                               
|   |________________|    |           
|         |____|          |  
|_________________________|

It is not the most beautiful look but that should achieve what you want as far as I understood your question.这不是最漂亮的外观,但据我了解您的问题,这应该可以达到您想要的效果。 You don´t need special libraries to accomplish simple graphical illustrations in the console.您不需要特殊的库来在控制台中完成简单的图形插图。

How to print compacted points in pure C, so they can be seen as a single mathematical figure (line, square, rectangle, etc.)?如何在纯 C 中打印压缩点,以便将它们视为单个数学图形(线、正方形、矩形等)?

A console is not meant to output shapes and figures like that.控制台不适用于 output 形状和图形。 Maybe there are some terminals with special fonts, but it is hard if not impossible to achieve.也许有些终端有特殊的fonts,但即使不是不可能,也很难实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在C和Linux中打印黑桃,心形,菱形等? - How to print spades, hearts, diamonds, etc. in C and Linux? 信号处理:如何解析代码和状态,以便WIFEXITED等可以使用它们? - Signal handling: how to parse code and status so WIFEXITED etc. can use them? 如何在 c 的一行中打印不同的 arrays? - How to print different arrays in a single line in c? 如何让 C 程序向文件内容添加行号。 例如,“1. #include<stdio.h> 2.#include<stdlib.h> “, ETC。?</stdlib.h></stdio.h> - How can you make a C program add line numbers to a file's contents. E.g., "1. #include <stdio.h> 2. #include <stdlib.h>", etc.? 我可以在C中将0.16、0.32等正确转换为整数(16、32等)吗? - Can I convert 0.16, 0.32, etc. into an integer properly (16, 32, etc.) in C? 我如何在单行上打印数字 - How can i print numbers on single line C点形成矩形 - C points forming rectangle 如何突出显示C语言的数学运算符,例如“ *”,“ +”,“-”等? - How to highlight math operators like '*' '+' '-' etc. for c language? 如何在 C 的单行上制作倒数计时器打印结果? - How to make countdown timer print result on single line in C? 如果 C 只能返回一个值(int、char 等),那么它如何返回字符串文字(字符数组)? - If C can return only one value(int , char etc.) then how does it returns character string literal(array of chars)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM