課程
/后端開發(fā)
/C#
/C#開發(fā)輕松入門
這個代碼應(yīng)該怎么敲,最好把自己看到這道題的思路詳細的說一下。謝謝大神了!
2018-07-13
源自:C#開發(fā)輕松入門 4-10
正在回答
????????????????int x=1; //輔助判斷??????????? //外層循環(huán)控制輸出多少行(用a--方便后面輸出o)??????????? for(int a=7;a>=1;a--){??????????????? //內(nèi)層循環(huán)控制輸出多少列??????????????? for(int b = 1;b<=7;b++){??????????????????? //控制一行中哪一列輸出 o,哪一列輸出 .??????????????????? if(b==x || b==a){ //當b==x時,每一行按 第1 2 3 4 5 6 7 位輸出o(也就是示例圖上從左到右的 o)
????????????????????????????????????????????????//當b==a時,每一行按 第7 6 5 4 3 2 1 位輸出o(也就是示例圖從右到左的 o)
??????????????????????? Console.Write("o");??????????????????? }else{??????????????????? Console.Write(".");??????????????????? }??????????????? }??????????????? x++;??????????????? Console.WriteLine();??????????? }
//(這種形式的,一般都是先外層循環(huán)控制多少行,然后內(nèi)層循環(huán)控制每一行有多少列,然后控制每一行輸出什么)
qq_朱與墨的晴霜_0
阿龍0326
? ? ? ? static void Main(string[] args)
??????? {??????????? //請完善代碼??????????? for(int i = 0;i<7;i++)??????????? {??????????????? for(int j = 0;j<7;j++)??????????????? {??????????????????? if(i == j||i==6-j)??????????????????????? Console.Write("O");??????????????????? else??????????????????????? Console.Write(".");??????????????? }??????????????? Console.WriteLine();??????????? }??????? }
? ? ? ? {
? ? ? ? ? ? //請完善代碼
? ? ? ? ? ? for (int i = 1; i <= 7; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? for (int j = 1; j <= 7; j++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? if (j == 8 - i || j == 8 - (8 - i))
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? Console.Write("0");
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? ? ? Console.Write(".");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? Console.WriteLine("");
? ? ? ? ? ? }
? ? ? ? }
?static void Main(string[] args)
? ? ? ? ? ? int z =7;
? ? ? ? ? ? for(int x=1;x<=7;x++){
? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ?for(int y=1;y<=7;y++){
? ? ? ? ? ? ? ? ? ? ?if(y==x||y==z){
? ? ? ? ? ? ? ? ? ? ? ? ?Console.Write("O");
? ? ? ? ? ? ? ? ? ? ?}else{
? ? ? ? ? ? ? ? ? ? ? ? ?Console.Write(".");
? ? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ?z--;
? ? ? ? ? ? ? ? ? Console.WriteLine(" ");
? ? ? ? ? ??
using System;
using System.Collections.Generic;
using System.Text;
namespace Test
{
? ? class Program
? ? {
? ? ? ? ? ? for(int x=1;x<=7;x++)
? ? ? ? ? ? ? ?for(int y=1;y<=7;y++)
? ? ? ? ? ? ? ?{
? ? ? ? ? ? ? ? ? ?string text= x==y||x+y==8 ? "O": ".";
? ? ? ? ? ? ? ? ? ?Console.Write(text);
? ? ? ? ? ? ? ? Console.WriteLine();
? ? }
}
首先二維數(shù)組的位置編號二維數(shù)組左上角的是(0,0)
示例如下
(0,0)? (0,1)?? (0,2)
(1,0)? (1,1)?? (1,2)
(2,0)? (2,1)?? (2,2)
舉報
本門課程是C#語言的入門教程,將帶你輕松入門.NET開發(fā)
3 回答求教各路大神
3 回答求解 大神們
2 回答C#求解大神
4 回答大神求解答
1 回答求大神解答
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學習伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2018-07-31
????????????????int x=1; //輔助判斷
??????????? //外層循環(huán)控制輸出多少行(用a--方便后面輸出o)
??????????? for(int a=7;a>=1;a--){
??????????????? //內(nèi)層循環(huán)控制輸出多少列
??????????????? for(int b = 1;b<=7;b++){
??????????????????? //控制一行中哪一列輸出 o,哪一列輸出 .
??????????????????? if(b==x || b==a){ //當b==x時,每一行按 第1 2 3 4 5 6 7 位輸出o(也就是示例圖上從左到右的 o)
????????????????????????????????????????????????//當b==a時,每一行按 第7 6 5 4 3 2 1 位輸出o(也就是示例圖從右到左的 o)
??????????????????????? Console.Write("o");
??????????????????? }else{
??????????????????? Console.Write(".");
??????????????????? }
??????????????? }
??????????????? x++;
??????????????? Console.WriteLine();
??????????? }
//(這種形式的,一般都是先外層循環(huán)控制多少行,然后內(nèi)層循環(huán)控制每一行有多少列,然后控制每一行輸出什么)
2018-08-08
? ? ? ? static void Main(string[] args)
??????? {
??????????? //請完善代碼
??????????? for(int i = 0;i<7;i++)
??????????? {
??????????????? for(int j = 0;j<7;j++)
??????????????? {
??????????????????? if(i == j||i==6-j)
??????????????????????? Console.Write("O");
??????????????????? else
??????????????????????? Console.Write(".");
??????????????? }
??????????????? Console.WriteLine();
??????????? }
??????? }
2018-08-03
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? //請完善代碼
? ? ? ? ? ? for (int i = 1; i <= 7; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? for (int j = 1; j <= 7; j++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? if (j == 8 - i || j == 8 - (8 - i))
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? Console.Write("0");
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? Console.Write(".");
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? Console.WriteLine("");
? ? ? ? ? ? }
? ? ? ? }
2018-08-01
?static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? int z =7;
? ? ? ? ? ? for(int x=1;x<=7;x++){
? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ?for(int y=1;y<=7;y++){
? ? ? ? ? ? ? ? ? ? ?if(y==x||y==z){
? ? ? ? ? ? ? ? ? ? ? ? ?Console.Write("O");
? ? ? ? ? ? ? ? ? ? ?}else{
? ? ? ? ? ? ? ? ? ? ? ? ?Console.Write(".");
? ? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ?z--;
? ? ? ? ? ? ? ? ? Console.WriteLine(" ");
? ? ? ? ? ? }
? ? ? ? ? ??
? ? ? ? }
2018-07-22
using System;
using System.Collections.Generic;
using System.Text;
namespace Test
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? for(int x=1;x<=7;x++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ?for(int y=1;y<=7;y++)
? ? ? ? ? ? ? ?{
? ? ? ? ? ? ? ? ? ?string text= x==y||x+y==8 ? "O": ".";
? ? ? ? ? ? ? ? ? ?Console.Write(text);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? Console.WriteLine();
? ? ? ? ? ? }
? ? ? ? }
? ? }
}
2018-07-14
首先二維數(shù)組的位置編號二維數(shù)組左上角的是(0,0)
示例如下
{
(0,0)? (0,1)?? (0,2)
(1,0)? (1,1)?? (1,2)
(2,0)? (2,1)?? (2,2)
}