洋葱刺激眼睛:C 语言图形输出问题
来源:百度文库 编辑:查人人中国名人网 时间:2024/04/29 01:29:11
*
***
*****
*******
*********
***********
*************
***************
用C语言怎么写,用for循环,不用printf("*"),
***
*****
*******
*********
***********
*************
***************
用C语言怎么写,用for循环,不用printf("*"),
#include<stdio.h>
int main(void)
{
int i,j;
for(i=1;i<=8;i++)
{
for(j=1;j<=2*i-1;j++)
printf("*");
printf("\n");
}
return 0;
}
// zd_25.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <string.h>
int main(int argc, char* argv[])
{
char str[30]="*";
char temp[3]="**";
for(int i=0;i<8;i++)
{
printf("%s\n",str);
strcat(str,temp);
}
return 0;
}
输出:
*
***
*****
*******
*********
***********
*************
***************
Press any key to continue
VC下写的啊。。。