# 我愛柯世文
cool
```cpp=
#include <stdio.h>
#define SIZE 100
// function to print the dimensional array
void printArray(int a[SIZE][SIZE], int n){
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
printf("%c ", a[i][j]);
}
printf("\n");
}
}
// function to print the menu
void printMenu(){
printf("Please choose which pattern you want to print: (Enter [1/2/3/4])\n");
printf("1: Print triangle\n");
printf("2: Rotate triangle 90 degrees\n");
printf("3: Rotate specified rotate angle\n");
printf("4: End program\n");
}
// function to rotate the dimensional array clockwise 90 degree
void rotateArray90Degrees(int begin[SIZE][SIZE], int after[SIZE][SIZE], int n){
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
after[j][i] = begin[(n-1)-i][j];
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
begin[i][j] = after[i][j];
}
}
}
// function to rotate the dimensional array clockwise 180 degree
void rotateArray180Degrees(int begin[SIZE][SIZE], int after[SIZE][SIZE], int n){
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
after[(n-1)-i][(n-1)-j] = begin[i][j];
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
begin[i][j] = after[i][j];
}
}
}
// function to rotate the dimensional array clockwise 270 degree
void rotateArray270Degrees(int begin[SIZE][SIZE], int after[SIZE][SIZE], int n){
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
after[(n-1)-j][i] = begin[i][j];
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
begin[i][j] = after[i][j];
}
}
}
int main(){
// declare all variables
int size, mode, angle, tri[SIZE][SIZE] = {0}, tmp[SIZE][SIZE];
printf("Please enter the size of triangle: ");
scanf("%d", &size);
// check whether the input number is within the range
while(size <= 0){
printf("The size should be positive. Try again: ");
scanf("%d", &size);
}
// establish the triangle
for(int i = 0; i < size; i++){
for(int j = 0; j < size; j++){
if(i >= j) tri[i][j] = '*';
else tri[i][j] = '0';
}
}
printMenu();
scanf("%d", &mode);
while(mode != 4){
if(mode == 1){
// if the input number is 1 will print the triangle
printArray(tri, size);
printMenu();
scanf("%d", &mode);
}else if(mode == 2){
// if the input number is 2 will rotate the triangle 90 degree
rotateArray90Degrees(tri, tmp, size);
printf("Received. Rotate the triangle 90 degree.\n");
printMenu();
scanf("%d", &mode);
}else if(mode == 3){
// if the input number is 3 will rotate the triangle in specified angles
printf("Please enter the specified angle(the angle must be a multiple of 90): ");
scanf("%d", &angle);
// check whether the input number is within the range
while(angle % 90 != 0){
printf("The input number should be the multiple of 90. Try again: ");
scanf("%d", &angle);
}
printf("Received. Rotate the triangle %d degree.\n", angle);
// adjust the angle
while(angle < 0) angle += 360;
while(angle > 360) angle -= 360;
if(angle == 0){
// do nothing
}else if(angle == 90){
rotateArray90Degrees(tri, tmp, size);
}else if(angle == 180){
rotateArray180Degrees(tri, tmp, size);
}else if(angle == 270){
rotateArray270Degrees(tri, tmp, size);
}
printMenu();
scanf("%d", &mode);
}else{
// check whether the input number is within the range
printf("The input number should be 1 to 4. Try again: ");
scanf("%d", &mode);
}
}
// if the input number is 4 will end the program
printf("End Program");
}
```