*****
*****
*****
*****
*****
分别用:(1)C语言中的字符数组方法;(2)C++中的string 方法
#include<iostream>//C++
#include<string>
using namespace std;
void TFboy(int n)
{
int i;
for(i=0;i<n;i++)
{
cout<<" ";
}
}
int main()
{
string a="*****";
for(int i=0;i<5;i++)
{
TFboy(i);
cout<<a<<endl;
}
system("pause");
return 0;
}
#include<stdio.h>//C
#include<string.h>
void TFboy(int n)
{
int i;
for(i=0;i<n;i++)
{
printf(" ");
}
}
int main()
{
char a[5]={'*','*','*','*','*'};
for(int i=0;i<5;i++)
{
TFboy(i);
for(int j=0;j<5;j++)
{
printf("%c",a[j]);
}
printf("\n");
}
system("pause");
return 0;
}