小编m3k*_*3r1的帖子

无法在C中获得钻石形状

我正在做运动,用'#'做一个钻石形状,使用一个功能.我的代码:

    #include <stdio.h>
//Declare function
void losangle(int n);
//main
int main(void){
  int n;
  do {
    printf("Altura do triangulo: ");
    scanf("%d", &n );
  } while( n % 2 == 0);
  losangle(n);}
//function
void losangle(int n){
  int i, hashtag, spaces, j, spaces1, hashtag1;
//triangle
  for(i = 0; i < n; i++){
    for(spaces = 0; spaces < (n-i); spaces++){
      printf(" ");}
    for(hashtag = 0; hashtag < (i+1);hashtag++){
      printf("# ");}
    printf("\n");}
//inverted triangle
  for(j = 0; j < (n - 1); j++){
    for(spaces1 = …
Run Code Online (Sandbox Code Playgroud)

c shape

0
推荐指数
1
解决办法
108
查看次数

标签 统计

c ×1

shape ×1