Form1 Form Groupbox Radiobutton Radiobutton Radiobutton Radiobutton Radiobutton Radiobutton Button
Form1 Form Groupbox Radiobutton Radiobutton Radiobutton Radiobutton Radiobutton Radiobutton Button
using
using
using
using
using
using
System;
System.Drawing;
System.Collections;
System.ComponentModel;
System.Windows.Forms;
System.Data;
// radioButton1
//
this.radioButton1.Location = new System.Drawing.Point(8, 20);
this.radioButton1.Name = "radioButton1";
this.radioButton1.TabIndex = 4;
this.radioButton1.Text = "Problema 1";
this.radioButton1.CheckedChanged += new
System.EventHandler(this.radioButton1_CheckedChanged);
//
// radioButton2
//
this.radioButton2.Location = new System.Drawing.Point(8, 50);
this.radioButton2.Name = "radioButton2";
this.radioButton2.TabIndex = 5;
this.radioButton2.Text = "Problema 2";
this.radioButton2.CheckedChanged += new
System.EventHandler(this.radioButton2_CheckedChanged);
//
// radioButton3
//
this.radioButton3.Location = new System.Drawing.Point(8, 80);
this.radioButton3.Name = "radioButton3";
this.radioButton3.TabIndex = 6;
this.radioButton3.Text = "Problema 3";
this.radioButton3.CheckedChanged += new
System.EventHandler(this.radioButton3_CheckedChanged);
//
//radioButton4
this.radioButton4.Location = new System.Drawing.Point(8, 110);
this.radioButton4.Name = "radioButton4";
this.radioButton4.TabIndex = 7;
this.radioButton4.Text = "Problema 4";
this.radioButton4.CheckedChanged += new
System.EventHandler(this.radioButton4_CheckedChanged);
//
//radioButton5
this.radioButton5.Location = new System.Drawing.Point(8, 140);
this.radioButton5.Name = "radioButton5";
this.radioButton5.TabIndex = 8;
this.radioButton5.Text = "Problema 5";
this.radioButton5.CheckedChanged += new
System.EventHandler(this.radioButton5_CheckedChanged);
//
//radioButton6
this.radioButton6.Location = new System.Drawing.Point(8, 170);
this.radioButton6.Name = "radioButton3";
this.radioButton6.TabIndex = 9;
this.radioButton6.Text = "Problema 6";
this.radioButton6.CheckedChanged += new
System.EventHandler(this.radioButton6_CheckedChanged);
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(408, 317);
this.Controls.AddRange(new System.Windows.Forms.Control[] {this.groupBox1});
this.Name = "Form1";
this.Text = "Laboratorul Nr.1------MIDPS";
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
static void Main()
{
Application.Run(new Form1());
}
}
}
private void radioButton4_CheckedChanged(object sender, System.EventArgs e)
{
if (radioButton4.Checked)
{
Console.Clear();
int nota;
string s;
bool b;
b = true;
while (b)
{
Console.WriteLine("Introduceti nota:");
s = Console.ReadLine();
nota = Convert.ToInt32(s);
if (nota > 4 && nota <= 10)
{
Console.WriteLine("Studentul a trecut cu succes examenul,nota valida");
}
else
{
Console.WriteLine("Nota este invalida");
Console.ReadKey();
Environment.Exit(0);
}
}
}
}
private void radioButton5_CheckedChanged(object sender, System.EventArgs e)
{
if (radioButton5.Checked)
Console.Clear();
bool b;
b = true;
while (b)
{
Console.WriteLine("Introduceti un numar 1-7:");
int tmp = Convert.ToInt32(Console.ReadLine());
switch (tmp)
{
case 1:
Console.WriteLine("Ziua selectata este Luni");
break;
case 2:
Console.WriteLine("Ziua selectata este Marti");
break;
case 3:
Console.WriteLine("Ziua selectata este Miercuri");
break;
case 4:
Console.WriteLine("Ziua selectata este Joi");
break;
case 5:
Console.WriteLine("Ziua selectata este Vineri");
break;
case 6:
Console.WriteLine("Ziua selectata este Simbata");
break;
case 7:
Console.WriteLine("Ziua selectata este Duminica");
break;
default:
Console.WriteLine("Selectare invalida.Alegeti variantele 1-7.");
break;
case 0:
Environment.Exit(0);
break;
}
}
}
private void radioButton6_CheckedChanged(object sender, System.EventArgs e)
{
if (radioButton6.Checked)
{
Console.Clear();
Console.WriteLine("Introduceti numarul de elemente al vectorului:");
int n = int.Parse(Console.ReadLine());
int[] tab = new int[n];
int aux;
for (int i = 0; i < n; i++)
{
Console.WriteLine("Elementul {0} este: ", i);
tab[i] = int.Parse(Console.ReadLine());
}
// selectie directa
for (int i = 0; i < n - 1; i++)
for (int j = i + 1; j < n; j++)
if (tab[j] > tab[i])
{
aux = tab[i];
tab[i] = tab[j];
tab[j] = aux;
}
//afisarea sirului sortat
Console.WriteLine("Sirul sortat este:");
Problema 2:
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
namespace Test_Grila
{
class Program
{
static void Main(string[] args)
{
int coeff = 0;
Console.WriteLine("SUNTETI GATA DE TEST?VA UREZ SUCCES!!!");
Console.WriteLine();
Console.WriteLine("I.Care este capitala Lituaniei ?");
Console.WriteLine();
Console.WriteLine("1.Riga");
Console.WriteLine("2.Vilnius");
Console.WriteLine("3.Reikjavic");
Console.WriteLine("4.Sofia");
Console.WriteLine();
Console.Write("Varianta corecta:");
int n = Convert.ToInt32(Console.ReadLine());
switch (n)
{
case 1:
break;
case 2:
coeff += 10;
break;
case 3:
break;
case 4:
break;
default:
Console.WriteLine("Selectare invalida");
break;
}
Console.Clear();
Console.WriteLine("II.La ce club evolueaza in prezent portarul roman Costel
Pantelimon?");
Console.WriteLine();
Console.WriteLine("1.Real Madrid");
Console.WriteLine("2.Manchester United");
Console.WriteLine("3.Barcelona");
Console.WriteLine("4.Manchester City");
Console.WriteLine();
Console.Write("Varianta corecta:");
int m = Convert.ToInt32(Console.ReadLine());
switch (m)
{
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
coeff += 10;
break;
}
Console.Clear();
Console.WriteLine("III.Ce inaltime are Turnul Eiffel:");
Console.WriteLine();
Console.WriteLine("1.520 m");
Console.WriteLine("2.290 m");
Console.WriteLine("3.324 m");
Console.WriteLine("4.382 m");
Console.WriteLine();
Console.Write("Varianta corecta:");
int i = Convert.ToInt32(Console.ReadLine());
switch (i)
{
case 1:
break;
case 2:
break;
case 3:
coeff += 10;
break;
case 4:
break;
}
Console.Clear();
Console.WriteLine("IV.Citi ani a domnit Stefan cel Mare:");
Console.WriteLine();
Console.WriteLine("1.47 ani");
Console.WriteLine("2.23 ani");
Console.WriteLine("3.55 ani");
Console.WriteLine("4.19 ani");
Console.WriteLine();
Console.Write("Varianta corecta:");
int j = Convert.ToInt32(Console.ReadLine());
switch (j)
{
case 1:
coeff += 10;
break;
case 2:
break;
case 3:
break;
case 4:
break;
}
Console.Clear();
Console.WriteLine("1.40");
Console.WriteLine("2.32");
Console.WriteLine("3.53");
Console.WriteLine("4.35");
Console.WriteLine();
Console.Write("Varianta corecta:");
int b = Convert.ToInt32(Console.ReadLine());
switch (b)
{
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
coeff += 10;
break;
}
Console.Clear();
Console.WriteLine("IX.In ce an s-a stins din viata Mihai Eminescu:");
Console.WriteLine();
Console.WriteLine("1.1896");
Console.WriteLine("2.1902");
Console.WriteLine("3.1889");
Console.WriteLine("4.1884");
Console.WriteLine();
Console.Write("Varianta corecta:");
int c = Convert.ToInt32(Console.ReadLine());
switch (c)
{
case 1:
break;
case 2:
break;
case 3:
coeff += 10;
break;
case 4:
break;
}
Console.Clear();
Console.WriteLine("X.Cine este actalul 'presedinte' al Republicii Moldova:");
Console.WriteLine();
Console.WriteLine("1.Vlad Filat");
Console.WriteLine("2.Nicolae Timofti");
Console.WriteLine("3.Vlad Plahotniuc");
Console.WriteLine("4.Marian Lupu");
Console.WriteLine();
Console.Write("Varianta corecta:");
int t = Convert.ToInt32(Console.ReadLine());
switch (t)
{
case 1:
break;
case 2:
coeff += 10;
break;
case 3:
break;
case 4:
break;
}
Console.Clear();
Console.WriteLine("Ati acumulat:"+ coeff+"puncte");
if (coeff>=0 && coeff<=20) {Console.WriteLine("Aveti o cultura generala vaga.Nu ar
strica sa cititi niste carti.");}
if (coeff > 20 && coeff <= 50) { Console.WriteLine("Cultura generala a dvs este la nivel
mediu."); }
Concluzie:
Efectuind aceasta lucrare de laborator am studiat bazele
programarii in C#.Prima problema am rezolvat utilizind o forma
pentru a comuta problemele.Testul l-am realizat simplu utilizind
doar instructiunea switch,case.
Rapport
Travail de laboratoire Nr.1
Discpline:MIDPS
Theme:Etudier les notions de base C#
A elabore:
et.gr.FI-101
Turetchi Gheorghe
A verifie:
professeur
Antohi Ionel
Chisinau 2013
Problme1 : Salut
Rcrire le programme salut pour qu'il affiche un message personnalis pass sur la
ligne de commande.
Ex : Hello : de moi mme!
Problme2 : Strings
Le string pass sur la ligne de commande, doit saffiche en ordre inverse.
Ex : introduisez 12345 , return 54321
Problme3 : Oprations
Ecrire un programme qui lit deux strings passs sur la ligne de commande et quand
on appuie sur : 1 - affiche le concatnation, 2- affichage du premire string, 3affichage du deuxime string.
Problme4 : Notes
Ecrire un programme qui lit une note passe sur la ligne de commande et qui
indique si elle est suffisante pour russir un examen. Si cest pas une note valide
alors faites le sortir du programme avec Environment.Exit()
Problme5 : Mois
Ecrire un programme qui lit le nombre entier entre 1 et 7 pass en paramtre et qui
affiche le nom de la jour correspondant.
Problme6 : Tableau
Ecrire un programme qui sorte un tableau de 10 lments en ordre dcroissant
(selon le dsir sans un algorithme exact), les lments sont pris de la ligne de
commande.
Faire un petite test dans Visual Studio, type Console Application, langage C#.
Ex :
I .Votre qualit principale, cest dtre ?
1. Optimiste (1p)
2. Tolrant (1p)
3. Davoir une bonne facult danalyse (1p)
4. Efficace (1p)
Chaque rponse est estim avec un score quelconque, la fin du test on peut
obtenir une somme de ces points et en dpendance du score accumul on nous
affiche une caractristique de notre personnalit.