注册 登录
编程论坛 C语言论坛

求一个图形函数

Pa407 发布于 2023-08-25 18:59, 574 次点击
msdos环境下,求一个100*100的写屏函数,能让我在特定的位置写信息。我要4*4的格子,在每个格子里写不同的数组值。。。。。
6 回复
#2
Pa4072023-08-25 19:03
9宫格是3*3,我要4*4
#3
forever742023-08-25 19:21
编译器?版本?
一定要图形模式?还是仅仅要定位写字符?
#4
Pa4072023-08-26 08:23
# include <stdio.h>

int main()
{
    int i,j;
    for (i=0;i<49;i++)
        {
            printf("\n");
            for (j=0;j<121;j++)
                {
                    if ( (i%12==0      )||( j%30==0     )                   )
                        printf("*");
                    else   if ((i>0)&&(i<12)&&(j>0)&&(j<30)) printf("4");
                    else   if ((i>12)&&(i<24)&&(j>0)&&(j<30)) printf("3");
                    else   if ((i>24)&&(i<36)&&(j>0)&&(j<30)) printf("2");
                    else   if ((i>36)&&(i<48)&&(j>0)&&(j<30)) printf("1");
                    else   if ((i>0)&&(i<12)&&(j>30)&&(j<60)) printf("5");
                    else   if ((i>0)&&(i<12)&&(j>60)&&(j<90)) printf("6");
                    else   if ((i>0)&&(i<12)&&(j>90)&&(j<120)) printf("7");
                    else   if ((i>12)&&(i<24)&&(j>90)&&(j<120)) printf("8");
                    else   if ((i>24)&&(i<36)&&(j>90)&&(j<120)) printf("9");      
                    else   if ((i>36)&&(i<48)&&(j>90)&&(j<120)) printf("A");
                    else   if ((i>36)&&(i<48)&&(j>60)&&(j<90)) printf("B");
                    else   if ((i>36)&&(i<48)&&(j>30)&&(j<60)) printf("C");   
                    else     printf(" ") ;
                }     
        }   
  return 0;   
}
#5
Pa4072023-08-26 08:38
接下来要写一个函数,替代printf("4");
就是定位写字符。比如数组,字符串等都
#6
rjsp2023-08-28 15:39
回复 4楼 Pa407
完全听不懂你想要什么。但就你这段代码来看,可读性不高,我帮你改写一下

程序代码:
#include <stdio.h>
#include <assert.h>

int main( void )
{
    const size_t a_row = 4;
    const size_t a_col = 4;
    const size_t b_row = 11;
    const size_t b_col = 29;
    const char cs[] = "45673  82  91CBA";
    assert( sizeof(cs) > a_row*a_col );

    for( size_t r=0; r!=1+a_row+a_row*b_row; ++r )
    {
        putchar( '\n' );
        for( size_t c=0; c!=1+a_col+a_col*b_col; ++c )
        {
            if( r%(1+b_row)==0 || c%(1+b_col)==0 )
                putchar( '*' );
            else
            {
                const size_t a_r = r/(1+b_row);
                const size_t a_c = c/(1+b_col);
                putchar( cs[a_r*a_row+a_c] );
            }
        }
    }
}
#7
yiyanxiyin2023-08-28 15:53
https://www.
1