#include "string.h"
void display(char * grid[11][6]){
for (int i = 0i <11i++) {
for (int j = 0j <6j++) {
printf("%7s ",grid[i][j])
}
printf("\n")
}
}
int getY(char * yid)
void set(char * yid,int x,char* c)
char* grid[11][6]
void init(){
for (int i = 0i <11i++) {
for (int j = 0j <6j++) {
grid[i][j] = (char *)""
}
}
grid[0][1] = (char *)"A"
grid[0][2] = (char *)"B"
grid[0][3] = (char *)"C"
grid[0][4] = (char *)"D"
grid[0][5] = (char *)"E"
grid[1][0] = (char *)"1"
grid[2][0] = (char *)"2"
grid[3][0] = (char *)"3"
grid[4][0] = (char *)"4"
grid[5][0] = (char *)"5"
grid[6][0] = (char *)"6"
grid[7][0] = (char *)"7"
grid[8][0] = (char *)"8"
grid[9][0] = (char *)"9"
grid[10][0] = (char *)"10"
}
int main(){
init()
set("A",1,"Andy")
display(grid)
return0
}
void set(char * yid,int x,char* c){
int y = getY(yid)
grid[x][y] = c
}
int getY(char * h_id){
if (strcmp(h_id, "A") == 0) {
return1
}
elseif(strcmp(h_id, "B") == 0){
return2
}
elseif(strcmp(h_id, "C") == 0){
return3
}
elseif(strcmp(h_id, "D") == 0){
return4
}
elseif(strcmp(h_id, "E") == 0){
return5
}
elsereturn -1
}
1、首先在打开的C语言软件中,如下图所示,添加stdio.h头文件。
2、然后添加main主函数,如下图所示。
3、接着在下一行,添加返回值return 0,如下图所示。
4、然后添加printf("A\tB\n")语句, \t可以输出空格,如下图所示。
5、接着点击!按钮,执行程序,如下图所示。
6、最后d出控制台,输出了A、B,成功输出了空格了,如下图所示就完成了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)