
帮忙把C++写的代码改成C#的。
代码#include"stdio.h"voidmain(){inti,j,n,a;chars='a';scanf("%d",&n);for(i=n;i>0;i--){fo...
代码
#include"stdio.h"
void main()
{
int i, j, n, a;
char s='a';
scanf("%d",&n);
for (i = n; i > 0; i--)
{
for(a=0;a<n-i;a++)
printf(" ");
for (j = 1; j < 2 * i; j++)
{
printf("%c",s);
s+=1;
if(s>'z')
s='a';
}
printf("\n");
}
}
运行结果
9
abcdefghijklmnopq
rstuvwxyzabcdef
ghijklmnopqrs
tuvwxyzabcd
efghijklm
nopqrst
uvwxy
zab
c
Press any key to continue
帮忙把C++写的代码改成C#的。
用VS2010写C++和C#,这两种代码都帮写下吧。学习中,帮帮忙吧! 展开
#include"stdio.h"
void main()
{
int i, j, n, a;
char s='a';
scanf("%d",&n);
for (i = n; i > 0; i--)
{
for(a=0;a<n-i;a++)
printf(" ");
for (j = 1; j < 2 * i; j++)
{
printf("%c",s);
s+=1;
if(s>'z')
s='a';
}
printf("\n");
}
}
运行结果
9
abcdefghijklmnopq
rstuvwxyzabcdef
ghijklmnopqrs
tuvwxyzabcd
efghijklm
nopqrst
uvwxy
zab
c
Press any key to continue
帮忙把C++写的代码改成C#的。
用VS2010写C++和C#,这两种代码都帮写下吧。学习中,帮帮忙吧! 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
展开全部
C#代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace toC_百度知道
{
class Program
{
static void Main(string[] args)
{
int i, j, n, a;
char s='a';
n=int.Parse(Console.ReadLine());
for (i = n; i > 0; i--)
{
for(a=0;a<n-i;a++)
Console.Write(" ");
for (j = 1; j < 2 * i; j++)
{
Console.Write("{0}",s);
s++;
if(s>'z')
s='a';
}
Console.Write("\n");
}
}
}
}
C++代码:
// C++代码_百度知道.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int i, j, n, a;
char s='a';
cin>>n;
for (i = n; i > 0; i--)
{
for(a=0;a<n-i;a++)
cout<<" ";
for (j = 1; j < 2 * i; j++)
{
cout<<s;
s+=1;
if(s>'z')
s='a';
}
cout<<endl;
}
return 0;
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace toC_百度知道
{
class Program
{
static void Main(string[] args)
{
int i, j, n, a;
char s='a';
n=int.Parse(Console.ReadLine());
for (i = n; i > 0; i--)
{
for(a=0;a<n-i;a++)
Console.Write(" ");
for (j = 1; j < 2 * i; j++)
{
Console.Write("{0}",s);
s++;
if(s>'z')
s='a';
}
Console.Write("\n");
}
}
}
}
C++代码:
// C++代码_百度知道.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int i, j, n, a;
char s='a';
cin>>n;
for (i = n; i > 0; i--)
{
for(a=0;a<n-i;a++)
cout<<" ";
for (j = 1; j < 2 * i; j++)
{
cout<<s;
s+=1;
if(s>'z')
s='a';
}
cout<<endl;
}
return 0;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询