1. 求助一道c語言題,從鍵盤輸入一個整數n,一個字母,輸出字母X圖形.
#include"stdio.h"
intmain(intargv,char*argc[]){
charn,c,i,t,N=40;
printf("Inputn(int0<n<13)&c(letter)... ");
if(scanf("%d%c",&n,&c)!=2||n<1||n>12||(c|0x20)<'a'||(c|0x20)+n+n-1>'z'){
printf("Inputerror,exit... ");
return0;
}
for(t=(n--<<1)-1,i=0;i<t;i++,c++){
if(i<n)
printf("%*.*s%c%*.*s%c ",N+i+1,1,"",c,t-i-i-2,1,"",c);
elseif(i==n)
printf("%*.*s%c ",N+t-i,1,"",c);
else
printf("%*.*s%c%*.*s%c ",N+t-i,1,"",c,i+i-t,1,"",c);
}
return0;
}
運行舉例: