View Code of Problem 125

#include<stdio.h>//8
main()
{
	int a,b,c,d,i,j,m,n;
	scanf("%d",&a);
	for(i=1;i<=2*a+3;i++)//判断是第几行
	{
		if(i==1||i==a+2||i==2*a+3)//如果是第一行,最后一行,中间一行
		{
			for(j=1;j<=a+2;j++)
			{
				if(j==1||j==a+2)//先输出空格,最后再输出空格
				printf(" ");
				else
					printf("-");//中间输出‘-’
			}
		}
	//	printf("\n");
		if(i!=1&&i!=a+2&&i!=2*a+3)//如果不是以上的三行
		{
			for(j=1;j<=a+2;j++)
			{
				if(j==1||j==a+2)//先输出|,最后一行再输出|
					printf("|");
				else			//在中间输出空格
				printf(" ");
			}
		}
		printf("\n");
	}

/*
Main.c:2:1: warning: return type defaults to 'int'
 main()
 ^
Main.c: In function 'main':
Main.c:30:2: error: expected declaration or statement at end of input
  }
  ^
Main.c:4:20: warning: unused variable 'n' [-Wunused-variable]
  int a,b,c,d,i,j,m,n;
                    ^
Main.c:4:18: warning: unused variable 'm' [-Wunused-variable]
  int a,b,c,d,i,j,m,n;
                  ^
Main.c:4:12: warning: unused variable 'd' [-Wunused-variable]
  int a,b,c,d,i,j,m,n;
            ^
Main.c:4:10: warning: unused variable 'c' [-Wunused-variable]
  int a,b,c,d,i,j,m,n;
          ^
Main.c:4:8: warning: unused variable 'b' [-Wunused-variable]
  int a,b,c,d,i,j,m,n;
        ^
*/

Double click to view unformatted code.


Back to problem 125