你要的是这样的吗?见图:
则程序为:
#include
void print(int N)
{
int i,j;
for(i=1;i<=N;i++)
{
for(j=0;j putchar(' '); for(j=1;j<=i;j++) printf("%d",j); for(j=i-1;j>0;j--) printf("%d",j); puts(""); } for(i=1;i<=N;i++) { for(j=0;j
putchar(' '); for(j=1;j<=N-i;j++) printf("%d",j); for(j=N-i-1;j>0;j--) printf("%d",j); puts(""); } } int main() { int N; scanf("%d",&N); print(N); return 0; }
Console.WriteLine("请输入一个数字,然后回车");
string strInput = Console.ReadLine();
int c = Convert.ToInt32(strInput);
Console.WriteLine("---------------");
for (int i = 1; i <= c; i++)
{
for (int k = 0; k < c - i; k++)
{
Console.Write("\t");
}
for (int j = 1; j <= i; j++)
{
Console.Write(j);
Console.Write("\t");
}
for (int k = i - 1; k > 0; k--)
{
Console.Write(k);
Console.Write("\t");
}
Console.WriteLine();
}
for (int i = c - 1; i > 0; i--)
{
for (int k = 0; k < c - i; k++)
{
Console.Write("\t");
}
for (int j = 1; j <= i; j++)
{
Console.Write(j);
Console.Write("\t");
}
for (int k = i - 1; k > 0; k--)
{
Console.Write(k);
Console.Write("\t");
}
Console.WriteLine();
}
Console.ReadKey(true);
begin
for i:=1 to 1000 do
if (i mod 3=0)and (i mod 5=0) then s:=s+i;
writeln(s);
end.
第二题:
var n,i,j:longint;
begin
readln(n);
for i:=1 to n do
begin
for j:=1 to i do write(j);
if i>1then for h:=i-1 downto 1 do write(h);
end;
for i:=n downto 1 to
begin
for j:=1 to n-1 do write(j);
for h:=n-2 downto 1 do write(h);
end;
end.
第三题:
var a,b,c:integer;
begin
for a:=1 to 100 do
-for b:=1 to 100 do
--for c:=1 to 100 do
---begin
-----if a*3+b*2+c div 2 =100 then
------if a+b+c=100 then begin write(a,' ',b,' ',c);
-------------------------------exit; end;
---end.
end.
第四题:
var s,p:string;
i,h,m,t:integer;
begin
p:='';
readln(s);
h:=length(s);
for i :=1 to h do
if ord(s[i])<90 then p:=p+s[i] else if p<>''
then begin writeln (p); p:=''; m:=m+1; t:=0; end;
if p<>'' then begin writeln(p);writeln(m+1);end else
writeln(m);
end.