问题描述
编写一个程序,首先输入一个整数,例如5,然后在屏幕上显示如下的图形(5表示行数):
* * * * *
* * * *
* * *
* *
*
特别注意
这种题一定要严格格式一样,虽然很简单。但是要注意细节啊。我就是被坑了。
参考代码
#include <iostream>//数据输入输出流
#include <string.h>//字符串操作函数
#include <stdio.h>//C的输入输出
#include <stdlib.h>//定义杂项函数及内存分配函数
#include <math.h>//C中的数学函数
#include <vector>//STL vetor容器
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int maxn = 100;
int main(){
int n,i,j;
scanf("%d",&n);
for(i=0;i<n;i++){
for(j=0;j<n-i;j++) printf("* ");/*注意星号后面有一个空格*/
printf("\n");
}
return 0;
}