for (initial condition; comparison; state change)
{
Loop body
}
Print 100 times Helloword
for (int i=0;i<100,i++)
{
Console.WriteLine ("Helloword");
}
Ask for 1-100 and
int s = 0;
for (int i=1;i<=100;i++)
{
s = s + i;
}
Console.WriteLine (s);
Console.ReadLine ();
//100 all 7 related numbers and, odd and, even, and
int s = 0;
for (int i = 1; i <=; i++)
{
if ((i% 7 = = 0) | | (i% 10 = = 7) | | (I/10 = = 7))
{
s = s + i;
}
}
Console.WriteLine (s);
Console.ReadLine ();
Within 100 of all prime numbers and
int sum = 0;
for (int i = 2; I <=100; i++)
{
int a = 0;
for (int j = 1; J <=i; J + +)
{
if (i% J = = 0)//If I can be divisible by itself and by a number other than 1, then he is not prime
{
a++;
}
}
if (a = = 2)//Can be divisible by only two, i.e. prime number
{
sum = sum + i;
Console.Write (i + "t");
}
}
Console.Write ("and" +sum);
Console.ReadLine ();
Print ☆, arrange into graphics
//Upper right
for (int m = 1; m < m++)
{
for (int n = 1; n <= m; n++)
{
Console.Write ("☆");
}
Console.Write ("\ n");
}
////right down
for (int m = ten; m > 1; m--)
{
for (int n = 1; n < m; n++)
{
Console.Write ("☆");
}
Console.Write ("\ n");
}
////Lower left
for (int m = 1; m < m++)
{
for (int n = 1; n < m; n++)
{
Console.Write ("");
}
for (int l = ten; l > m; l--)
{
Console.Write ("☆");
}
Console.Write ("\ n");
}
////on top left
for (int m = 1; m < m++)
{
for (int n = 9; n >m; n--)
{
Console.Write ("");
}
for (int l = 1; l <= m;l++)
{
Console.Write ("☆");
}
Console.Write ("\ n");
}
//Upper part
for (int m = 1; m < m++)
{
for (int n = 9; n > M; n--)
{
Console.Write ("");
}
for (int l = 1; l <= (2 * m-1); l++)
{
Console.Write ("☆");
}
Console.Write ("\ n");
}
////Lower half part
for (int m = 1; m < 9; m++)
{
for (int l = 1; l <= m; l++)
{
Console.Write ("");
}
for (int n = 1; n <= (2 * (9-M)-1); n++)
{
Console.Write ("☆");
}
Console.Write ("\ n");
}
//A pair of young rabbits grow into a rabbit one months later, and then grow into a rabbit in one months and give birth to a couple of rabbits, how many pairs of rabbits are there in two years? A relationship such as int a = 1, b = 0, c = 0;
for (int i = 2; I <=; i++)
{
if (i = = 1)
{
c = 0;
b = 0;
A = 1;
}
Else
{
c = c + B;
b = A;
A = C;
}
Console.WriteLine ("{0} months, number of rabbits: {1} Bunny number {2}: Number of young rabbits {3}", I, C, B, a);
Console.ReadLine ();
}
Console.WriteLine ("Total quantity is" + (C + A + b));
Console.ReadLine ();
//Poor lift problem: pencil a 2 yuan, pen box 5 yuan, folder 10 yuan, color pens 5 yuan, buy exactly 100 pieces of stationery, each kind at least buy one, enumerate all methodsfor (int qianbi = 1; qianbi <=; qianbi++)
{
for (int he = 1; he <=; he++)
{
for (int wenjianjia = 1; Wenjianjia <=; wenjianjia++)
{
for (int caibi = 1; caibi <= 7; caibi++)
{
int a = Qianbi * 2 + He * 5 + Wenjianjia * + Caibi * 15;
if (a = = 100)
{
Console.WriteLine ("Pencil buy {0} only, Box buy {1}, folder buy {2}, color pencils buy {3} branch", Qianbi, he, Wenjianjia, Caibi);
}
}
}
}
}
Console.ReadLine ();
C # for Loop