# 每五个一循环，该怎么搞？

-1
[已解决问题] 解决于 2014-08-15 14:18
```1 2 3 4 5

6 7 8 9 10

11 12 13 14 15

16 17 18 19 20

21 22 23 24 25

26 27 28 29 30```

每五个一循环，该怎么搞？ 我是for循环列出数据，添加五种css .

2 7 12 17 22 27用css B

3 8 13 18 23 28 用css C

4 9 14 19 24 29 用css D

5 10 15 20 25 30 用css E

int i=1;

foearch(var info in list)

{

//...

i++;

}

``` 1  public static string GetStyle(int type)
2         {
3             if ((type - 1)%5 == 0)
4             {
5                 return "A";
6             }
7             else if ((type - 2) % 5 == 0)
8             {
9                 return "B";
10             }
11             else if ((type - 3) % 5 == 0)
12             {
13                 return "C";
14             }
15             else if ((type - 4) % 5 == 0)
16             {
17                 return "D";
18             }
19             else if ((type - 5) % 5 == 0)
20             {
21                 return "E";
22             }
23             return "A";
24         }```

0

``` string html="";
html += "<table>";
string css="";
for (int i = 1; 1 <= 5; i++)
{
if (i == 1)
{
css = "A";
}
else if (i == 2)
{
css = "B";
}
else if (i == 3)
{
css = "C";

}
else if (i == 4)
{
css = "D";
}
else if (i == 5)
{
css = "E";
}
html += "<tr>";
for (int j = i; j < a.length; j + 5)
{
html += "<td class='"+css+"'>" + a[1] + "</td>";

}
html+="<tr>";
}
html += "</table>";
return html;```

1

lucika.zh | 园豆：62 (初学一级) | 2014-08-15 13:08
0

```static void Main(string[] args)
{
int num = 0;
for (int i = 1; i <=6; i++ ) {
for (int j = 1; j < 6;j++ ) {
num++;
Console.Write(num);
}
for (int k = 1; k < 6;k++ ) {
Console.WriteLine();
}
}
}```

```static void Main(string[] args)
{
int info = 47;//获取你的数据总条数赋值给info
for (int i = 0; i < info;i++ ) {
if(i%5==0){
Console.WriteLine();
}
Console.Write(i+1);
}
}```

0

您需要登录以后才能回答，未注册用户请先注册