> 백엔드 개발 > C++ > 본문

오른쪽 화살표와 왼쪽 화살표 패턴을 인쇄하는 프로그램을 C 언어로 작성하세요.

王林
풀어 주다: 2023-08-28 13:38:54
앞으로
1420명이 탐색했습니다.

프로그램 설명

왼쪽 및 오른쪽 화살표 패턴 인쇄

알고리즘

왼쪽 및 오른쪽 화살표 패턴 인쇄에 필요한 줄 수를 허용합니다.

Print Upper Part of the Arrow with Stars Patterns
Print Inverted Right Triangle with Stars Patterns
Print Bottom Part of the Arrow with Stars Patterns
Print the Right Triangle with Stars Patterns
로그인 후 복사

Example

/*Program to print the Left and right arrow pattern*/
#include<stdio.h>
int main() {
   int r, c, rows; //Left Arrow Pattern
   int r1, c1, rows1; //Right Arrow Pattern
   clrscr();
   printf("Enter number of rows to print the Left Arrow Pattern: ");
   scanf("%d", &rows);
   printf("</p><p>");
   printf("The Left Arrow Pattern is:");
   printf("</p><p>");
   for(r=1; r<rows; r++){
      for(c=1; c<=(rows-r); c++){
         printf(" ");
      }
      for(c=r;c<=rows; c++){
         printf("*");
      }
      printf("</p><p>");
   }
   for(r=1; r<=rows; r++){
      for(c=1; c<r; c++){
         printf(" ");
      }
      for(c=1; c<=r; c++){
         printf("*");
      }
      printf("</p><p>");
   }
   printf("Enter number of rows to print the Right Arrow Pattern: ");
   scanf("%d", &rows1);
   printf("</p><p>");
   printf("The Right Arrow Pattern is:");
   printf("</p><p>");
   for(r1=1; r1<rows1; r1++){
      for(c1=1; c1<=(2*r1-2); c1++){
         printf(" ");
      }
      for(c1=r1; c1<=rows1; c1++){
         printf("*");
      }
      printf("</p><p>");
   }
   for(r1=1; r1<=rows1; r1++){
      for(c1=1; c1<=(2*rows1 - 2*r1); c1++){
         printf(" ");
      }
      for(c1=1; c1<=r1; c1++){
         printf("*");
      }
      printf("</p><p>");
   }
   getch();
   return 0;
}
로그인 후 복사

Output

오른쪽 화살표와 왼쪽 화살표 패턴을 인쇄하는 프로그램을 C 언어로 작성하세요.

오른쪽 화살표와 왼쪽 화살표 패턴을 인쇄하는 프로그램을 C 언어로 작성하세요.

위 내용은 오른쪽 화살표와 왼쪽 화살표 패턴을 인쇄하는 프로그램을 C 언어로 작성하세요.의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

원천:tutorialspoint.com
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!