terça-feira, 27 de janeiro de 2015

Exercício C#: Ciclos for (2)

Fazer um projecto em C# que leia dois números inteiros, a e b, e imprima todos os números ímpares existentes no intervalo [a, b].

Colocar e resolução num comentário a este post.

25 comentários:

Alex Trifyutsyanu disse...

/*
* Created by SharpDevelop.
* User: Alex,Carlos
* Date: 27/01/2015
* Time: 10:44
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace Exblog27_01
{
class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Insira o 1º numero");
int a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Insira o 2º numero");
int b= Convert.ToInt32(Console.ReadLine());
for(int y=a ; a<=b; a++)


Console.Write(" {0}",a);
Console.ReadKey(true);
}
}
}

Anónimo disse...

*
* Created by SharpDevelop.
* User: pedro carreira
* Date: 27/01/2015
* Time: 11:07
*

*/
using System;

namespace t5
{class Program
{public static void Main(string[] args)
Console.WriteLine("Insira o 1º numero");
int a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Insira o 2º numero");
int b= Convert.ToInt32(Console.ReadLine());
for(int y=a ; a<=b; a++)


Console.Write(" {0}",a);
Console.ReadKey(true);
}}}

Anónimo disse...

/*
* Created by SharpDevelop.
* User: CarlosCorreia
* Date: 27/01/2015
* Time: 11:11
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace ciclo_2
{
class Program
{
public static void Main(string[] args)
{
int a, b;
Console.WriteLine("Insira o limite inferior");
a=Convert.ToInt16(Console.ReadLine() );
Console.WriteLine("Insira o limite superior");
b=Convert.ToInt16(Console.ReadLine() );
for(int i=a; i<=b ;i+=2)
Console.WriteLine (i);
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}


Carlos Correia nº3

Rui Monte disse...

namespace a
{
class Program
{
public static void Main(string[] args)
{
int c;
int a, b;
Console.WriteLine("Escreve um número a");
a = Convert.ToInt16(Console.ReadLine());
Console.WriteLine("Escreve um número b");
b = Convert.ToInt16(Console.ReadLine());
do
if (a>b){
Console.WriteLine("Escreva um número menor do que {0}.",b);
a = Convert.ToInt16(Console.ReadLine());
}
while (a>=b);
c = a;
c = c % 2;
if (c == 0) {
} else {
a = a + 1;
}



for (int i = a; i < b; i = i + 2) {
int x=i+1;
Console.WriteLine(x);

}
Console.ReadKey(true);
}
}
}

Tiago Monteiro disse...

namespace ciclo_2
{
class Program
{
public static void Main(string[] args)
{
int a, b;
Console.WriteLine("Insira o limite inferior");
a=Convert.ToInt16(Console.ReadLine() );
Console.WriteLine("Insira o limite superior");
b=Convert.ToInt16(Console.ReadLine() );
for(int i=a; i<=b ;i+=2)
Console.WriteLine (i);
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}

Ricardo L disse...

/*
* Created by SharpDevelop.
* User: Ricardo
* Date: 27/01/2015
* Time: 11:49
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace numerosimpares
{
class Program
{
public static void Main(string[] args)
{
int a, b;
Console.WriteLine("Insira o limite inferior");
a= Convert.ToInt16 (Console.ReadLine());
Console.WriteLine ("Insira o limite superior");
b= Convert.ToInt16 (Console.ReadLine());
for (int i=a ;i<=b; i+=2)
Console.WriteLine (i);

Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}

ricardo lage

Tiago Parente disse...

* Created by SharpDevelop.
* User: tiago parente
* Date: 27/01/2015
* Time: 11:50
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace numerosimpares
{
class Program
{
public static void Main(string[] args)
{
int a, b;
Console.WriteLine("Insira o limite inferior");
a= Convert.ToInt16 (Console.ReadLine());
Console.WriteLine ("Insira o limite superior");
b= Convert.ToInt16 (Console.ReadLine());
for (int i=a ;i<=b; i+=2)
Console.WriteLine (i);

Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}

Anónimo disse...

* Created by SharpDevelop.
* User: Ruben Morim
* Date: 27/01/2015
* Time: 11:49
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace exercicio 3
{
class Program
{
public static void Main(string[] args)
{
int a, b;
Console.WriteLine("Insira o limite inferior");
a= Convert.ToInt16 (Console.ReadLine());
Console.WriteLine ("Insira o limite superior");
b= Convert.ToInt16 (Console.ReadLine());
for (int i=a ;i<=b; i+=2)
Console.WriteLine (i);

Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}

Ruben Morim nº24

Anónimo disse...

Created by SharpDevelop.
* User: Marcelo Cruz
* Date: 27/01/2015
* Time: 11:07
*

*/
using System;

namespace ex
{class Programex
{public static void Main(string[] args)
Console.WriteLine("Insira o 1º numero");
int a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Insira o 2º numero");
int b= Convert.ToInt32(Console.ReadLine(););
for(int y=a ; a<=b; a++);

Ronaldo Veloso disse...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NumeroImpar
{
class Program
{
static void Main(string[] args)
{
int a, b, mod;
int i = 0;
Console.WriteLine("Insira o limite inferior");
a = Convert.ToInt16(Console.ReadLine());
do
{
Console.WriteLine("Insira o limite superior");
b = Convert.ToInt16(Console.ReadLine());
} while (b <= a);
mod = a % 2;
if (mod == 0)
{

for (i = a; i <= b; i = i + 2)
{
Console.WriteLine(i+1);
}
}
else
{
for (i = a; i <= b; i = i + 2)
{
Console.WriteLine(i);
}
}

Console.ReadKey();

}
}
}

Anónimo disse...

* Created by SharpDevelop.
* User: pedro carreira
* Date: 27/01/2015
* Time: 11:45
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace t3
{
class Program
{
public static void Main(string[] args)
{
int a, b;
Console.WriteLine("Insira o limite inferior");
a= Convert.ToInt16 (Console.ReadLine());
Console.WriteLine ("Insira o limite superior");
b= Convert.ToInt16 (Console.ReadLine());
for (int i=a ;i<=b; i+=2)
Console.WriteLine (i);

Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}}}

Anónimo disse...

/*
* Created by SharpDevelop.
* User: Luis Carreira
* Date: 27/01/2015
* Time: 11:31
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace ler_dois_numero_a_e_b
{
class Program
{
public static void Main(string[] args)
{
int a, b;
Console.WriteLine("Insira o limite inferior");
a= Convert.ToInt16 (Console.ReadLine());
Console.WriteLine ("Insira o limite superior");
b= Convert.ToInt16 (Console.ReadLine());
for (int i=a ;i<=b; i+=2)
Console.WriteLine (i);

Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}}}

Luis Quinta disse...

/*
* Created by SharpDevelop.
* User: Luis
* Date: 27/01/2015
* Time: 11:57
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace numeros_inteiros_soluçao_do_stor
{
class Program
{
public static void Main(string[] args)
{
int a,b;
Console.WriteLine("INSIRA O LIMITE INFERIOR");
a= Convert.ToInt16( Console.ReadLine());
Console.WriteLine("INSIRA O LIMITE SUPERIOR");
b = Convert.ToInt16( Console.ReadLine());
for( int i =a ; i <= b; i+=2 )
Console.WriteLine(i);
Console.ReadKey(true);
}
}
}

Sérgio Torres disse...

/*
* Created by SharpDevelop.
* User: Sérgio Torres
* Date: 27/01/2015
* Time: 11:46
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace project3
{
class Program
{
public static void Main(string[] args)
{ int a,b;
Console.WriteLine("insira o limite inferior");
a=Convert.ToInt16(Console.ReadLine());
Console.WriteLine("insira o limite superior");
b=Convert.ToInt16(Console.ReadLine());
for(int i=a ; i<=b ; i+=2)
Console.WriteLine(i);
Console.ReadKey (true);
}
}
}

Fábio Gomes disse...

/*
* Created by SharpDevelop.
* User: HP
* Date: 27/01/2015
* Time: 11:51
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace TRAB._3
{
class Program
{
public static void Main(string[] args)
{int a , b;
Console.WriteLine("insira o numero inferior");
a= Convert.ToInt16 (Console.ReadLine() );
Console.Write("insira o limite superior");
b = Convert.ToInt16 (Console.ReadLine () );
for ( int i=a ; i <=b ; i+=2)
Console.WriteLine (i);
Console.ReadKey (true);
}
}
}

Anónimo disse...

/*
* Created by SharpDevelop.
* User: Joao
* Date: 27/01/2015
* Time: 12:25
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace joao
{
class Program
{
public static void Main(string[] args)
int a,b
Console.WriteLine("Insira o limite anterior");
a=Convert.ToInt16 (Console.ReadLine()) ;
Console.WriteLine ("Insira um limite superior");
b=Convert.ToInt16(Console.ReadLine
for (int=a;int<=b;int+=2
Console.Writline

Alex Trifyutsyanu disse...

/*
* Created by SharpDevelop.
* User: Alex,Carlos
* Date: 27/01/2015
* Time: 10:44
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace Exblog27_01
{
class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Insira o 1º numero");
int a = Convert.ToInt32(Console.ReadLine());
if (a%2 ==0)
Console.WriteLine("Insira o 2º numero");
int b= Convert.ToInt32(Console.ReadLine());

for(int y=a ; a<=b; a=a+2)


Console.Write(" {0}",a);
Console.ReadKey(true);
}
}
}

Anónimo disse...

Diogo Nº4

using System;

namespace kakkvajfgadg
{
class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Insira o 1º nmr");
int a= Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Insira o 2º nmr");
int b= Convert.ToInt32(Console.ReadLine());
for(int y=a ; a<=b; a++)


Console.Write(" {0}",a);
Console.ReadKey(true);
}
}
}

joao sencadas disse...

/*
* Created by SharpDevelop.
* User: João Sencadas n 9
* Date: 27/01/2015
* Time: 11:28
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace impares
{
class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Insira o 1º numero");
int a= Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Insira o 2º numero");
int b= Convert.ToInt32(Console.ReadLine());
for(int y=a ; a<=b; a++)


Console.Write(" {0}",a);
Console.ReadKey(true);
}
}
}

helder boucinha disse...

namespace ciclo_2
{
class Program
{
public static void Main(string[] args)
{
int a, b;
Console.WriteLine("Insira o limite inferior");
a=Convert.ToInt16(Console.ReadLine() );
Console.WriteLine("Insira o limite superior");
b=Convert.ToInt16(Console.ReadLine() );
for(int i=a; i<=b ;i+=2)
Console.WriteLine (i);
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}

Anónimo disse...

/*
* Created by SharpDevelop.
* User: Luis Costa
* Date: 27/01/2015
* Time: 11:45
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace ler_dois_numero_a_e_b
{
class Program
{
public static void Main(string[] args)
{
int a, b;
Console.WriteLine("Insira o limite inferior");
a= Convert.ToInt16 (Console.ReadLine());
Console.WriteLine ("Insira o limite superior");
b= Convert.ToInt16 (Console.ReadLine());
for (int i=a ;i<=b; i+=2)
Console.WriteLine (i);

Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}}}

Anónimo disse...

/*
* Created by SharpDevelop.
* User: Ricardo
* Date: 27/01/2015
* Time: 11:49
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace numerosimpares
{
class Program
{
public static void Main(string[] args)
{
int a, b;
Console.WriteLine("Insira o limite inferior");
a= Convert.ToInt16 (Console.ReadLine());
Console.WriteLine ("Insira o limite superior");
b= Convert.ToInt16 (Console.ReadLine());
for (int i=a ;i<=b; i+=2)
Console.WriteLine (i);

Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}

José Ricardo Nº11

Anónimo disse...

* Time: 10:55
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace exercicio_ciclos
{
class Program
{
public static void Main(string[] args)
{

Console.WriteLine("Introduza um numero");
int a=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Introduza outro numero");
int b=Convert.ToInt32(Console.ReadLine());

if (b < a)
{
int c = a;
a = b;
b = c;
}

for (int i = a=a+1; i < b; i=i+1)
{
if( i % 2 != 0 )
Console.WriteLine(i);
}

Console.ReadKey();
}}}

Ricardo
Ze
Paulo

Anónimo disse...

/*
* Crea
ted by SharpDevelop.
* User: Diogo Flores
* Date: 27/01/2015
* Time: 11:15
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace exercicio
{
class Program
{
public static void Main(string[] args)
{int a,b;
Console.WriteLine("Insira o limite inferior");
a = Convert.ToInt16(Console.ReadLine());
Console.WriteLine("insira o limite superior");
b = Convert.ToInt16(Console.ReadLine());
for(int i=a;i<=b;i+=2)
Console.WriteLine(i);
}
}
}

Deadly Diogo disse...

diogo n4
using System;

namespace ADADFAS
{
class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Escreva o 1º nmr");
int a = Convert.ToInt32(Console.ReadLine());
if (a%2 ==0)
Console.WriteLine("Escreva o 2º nmr");
int b= Convert.ToInt32(Console.ReadLine());
for(int y=a ; a<=b; a=a+2)
Console.Write("{0}",a);
Console.ReadKey(true);
}
}
}