V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  WhileL  ›  全部回复第 1 页 / 共 1 页
回复总数  2
2018-09-29 11:28:16 +08:00
回复了 pinews 创建的主题 程序员 侄女的这道题难住我了,求助!
写个循环就好
int x = 1;//1 男 0 女
int n1 = 1;//男报数
int n0 = 1;//女报数
for (int i = 1; i <= 100; i++) {
x = (i % 2 == 0 ? (x==0?1:0) : (x==0?0:1));
Response.Write(i+":("+(x==1?"男报"+n1++:"女报"+n0++)+") ");
}

-------------------------------------------------------------------------------------------------------------------
1:(男报 1 ) 2:(女报 1 ) 3:(女报 2 ) 4:(男报 2 ) 5:(男报 3 ) 6:(女报 3 ) 7:(女报 4 ) 8:(男报 4 ) 9:(男报 5 ) 10:(女报 5 ) 11:(女报 6 ) 12:(男报 6 ) 13:(男报 7 ) 14:(女报 7 ) 15:(女报 8 ) 16:(男报 8 ) 17:(男报 9 ) 18:(女报 9 ) 19:(女报 10 ) 20:(男报 10 ) 21:(男报 11 ) 22:(女报 11 ) 23:(女报 12 ) 24:(男报 12 ) 25:(男报 13 ) 26:(女报 13 ) 27:(女报 14 ) 28:(男报 14 ) 29:(男报 15 ) 30:(女报 15 ) 31:(女报 16 ) 32:(男报 16 ) 33:(男报 17 ) 34:(女报 17 ) 35:(女报 18 ) 36:(男报 18 ) 37:(男报 19 ) 38:(女报 19 ) 39:(女报 20 ) 40:(男报 20 ) 41:(男报 21 ) 42:(女报 21 ) 43:(女报 22 ) 44:(男报 22 ) 45:(男报 23 ) 46:(女报 23 ) 47:(女报 24 ) 48:(男报 24 ) 49:(男报 25 ) 50:(女报 25 ) 51:(女报 26 ) 52:(男报 26 ) 53:(男报 27 ) 54:(女报 27 ) 55:(女报 28 ) 56:(男报 28 ) 57:(男报 29 ) 58:(女报 29 ) 59:(女报 30 ) 60:(男报 30 ) 61:(男报 31 ) 62:(女报 31 ) 63:(女报 32 ) 64:(男报 32 ) 65:(男报 33 ) 66:(女报 33 ) 67:(女报 34 ) 68:(男报 34 ) 69:(男报 35 ) 70:(女报 35 ) 71:(女报 36 ) 72:(男报 36 ) 73:(男报 37 ) 74:(女报 37 ) 75:(女报 38 ) 76:(男报 38 ) 77:(男报 39 ) 78:(女报 39 ) 79:(女报 40 ) 80:(男报 40 ) 81:(男报 41 ) 82:(女报 41 ) 83:(女报 42 ) 84:(男报 42 ) 85:(男报 43 ) 86:(女报 43 ) 87:(女报 44 ) 88:(男报 44 ) 89:(男报 45 ) 90:(女报 45 ) 91:(女报 46 ) 92:(男报 46 ) 93:(男报 47 ) 94:(女报 47 ) 95:(女报 48 ) 96:(男报 48 ) 97:(男报 49 ) 98:(女报 49 ) 99:(女报 50 ) 100:(男报 50 )
手机电脑都用五笔,感觉差不多
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2778 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 08:53 · PVG 16:53 · LAX 00:53 · JFK 03:53
Developed with CodeLauncher
♥ Do have faith in what you're doing.