課程
/后端開發(fā)
/C#
/C#開發(fā)輕松入門
請求給于幫助
2018-04-10
源自:C#開發(fā)輕松入門 4-10
正在回答
?for(int i = 0;i<7;i++){
? ? ? ? ? ? ? ? for(int j = 0;j<7;j++){
? ? ? ? ? ? ? ? ? ? if(j==i||i+j==6){
? ? ? ? ? ? ? ? ? ? ? ? Console.Write("o");
? ? ? ? ? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? ? ? ? ?Console.Write(".");
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? Console.WriteLine();//換行
? ? ? ? ? ? }
你這里是因為運算符的優(yōu)先級關(guān)系,“-”運算符的優(yōu)先級本來就要高于“==”運算符,把(8-x)的括號去掉就對了,希望能幫到你
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Test01
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? const int n = 7;
? ? ? ? ? ? for (int y = 1; y <= n; y++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? for (int x = 1; x <= n; x++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? if (x == y || x == n - y + 1)
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? Console.Write("O");
? ? ? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? ? ? Console.Write(".");
? ? ? ? ? ? ? ? Console.WriteLine();
? ? ? ? }
? ? }
}
const n = 7
for(y =1~n){
? for(x =1~n){
? ? if(x==y || x==n-y+1){
? ? ?output(0);
? ? output(*);
? }
? Change line;
}
??????????? for(int x=1;x<=7;x++)//循環(huán)行數(shù)??????????? {??????????????? ??????????????? for(int dot=1;dot<=7;dot++)//循環(huán)位數(shù)(位置從左到右為1234567)??????????????? {??????????????????? if (dot == x || dot == (8 - x))//判定位置,因為0為對稱位置,即8(最大位數(shù))減當(dāng)前位置可以得到之后位置。舉個例子,第一行第一個0在1位,所以第二個0在(8-1)=7位。??????????????????????? Console.Write("O");??????????????????? else??????????????????????? Console.Write(".");//其他位置打印“.”??????????????? }??????????????? Console.WriteLine();//換行??????????? }
初學(xué)乍道,望各位大佬不吝賜教!
俊醬 提問者
舉報
本門課程是C#語言的入門教程,將帶你輕松入門.NET開發(fā)
1 回答為什么報錯,結(jié)果能弄出來
3 回答沒寫出來
6 回答這個代碼的行數(shù)是怎么弄出來的
1 回答文字:高于平均分的,沒有輸出來
4 回答來學(xué)習(xí)的有沒有啊
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2018-06-26
?for(int i = 0;i<7;i++){
? ? ? ? ? ? ? ? for(int j = 0;j<7;j++){
? ? ? ? ? ? ? ? ? ? if(j==i||i+j==6){
? ? ? ? ? ? ? ? ? ? ? ? Console.Write("o");
? ? ? ? ? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? ? ? ? ?Console.Write(".");
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? Console.WriteLine();//換行
? ? ? ? ? ? }
2018-04-25
你這里是因為運算符的優(yōu)先級關(guān)系,“-”運算符的優(yōu)先級本來就要高于“==”運算符,把(8-x)的括號去掉就對了,希望能幫到你
2018-04-22
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Test01
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? const int n = 7;
? ? ? ? ? ? for (int y = 1; y <= n; y++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? for (int x = 1; x <= n; x++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? if (x == y || x == n - y + 1)
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? Console.Write("O");
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? Console.Write(".");
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? Console.WriteLine();
? ? ? ? ? ? }
? ? ? ? }
? ? }
}
2018-04-22
const n = 7
for(y =1~n){
? for(x =1~n){
? ? if(x==y || x==n-y+1){
? ? ?output(0);
? ? }
? ? output(*);
? }
? Change line;
}
2018-04-10
??????????? for(int x=1;x<=7;x++)//循環(huán)行數(shù)
??????????? {
???????????????
??????????????? for(int dot=1;dot<=7;dot++)//循環(huán)位數(shù)(位置從左到右為1234567)
??????????????? {
??????????????????? if (dot == x || dot == (8 - x))//判定位置,因為0為對稱位置,即8(最大位數(shù))減當(dāng)前位置可以得到之后位置。舉個例子,第一行第一個0在1位,所以第二個0在(8-1)=7位。
??????????????????????? Console.Write("O");
??????????????????? else
??????????????????????? Console.Write(".");//其他位置打印“.”
??????????????? }
??????????????? Console.WriteLine();//換行
??????????? }
初學(xué)乍道,望各位大佬不吝賜教!