Sreda, tsetverg, pjatnitsa }




Download 24.57 Kb.
Sana21.03.2017
Hajmi24.57 Kb.

using System;

using System.Text;


namespace Tallinn_2015sv_proge_al2

{

class Program



{

enum workDays



{

ponedelnik, vtornik, sreda,

tsetverg, pjatnitsa

}
struct Computer {

public String proisvoditel;

public double tsena;

public double protsessor;

public int RAM;

public int SD;


public void print() {

Console.WriteLine("{0,-10} {1,7:f2} {2,3:f1} {3,3} {4}",

proisvoditel, tsena,protsessor, RAM, SD);

}
}

static void Main(string[] args)



{

// EX1: sostavit enum (spisok snatsenii) , vkljutsat rabotsie dni

workDays vybrannyiDen = workDays.sreda;

Console.WriteLine("sobranie sostoitsa: {0}", vybrannyiDen);


// Ex2: sostavit strukturu Computer

// atributy: Proisvoditel,tsena,protsessor,RAM,SD,

// sostavit method print
Computer mylaptop;

mylaptop.proisvoditel = "Dell";

mylaptop.tsena = 600;

mylaptop.protsessor = 2.4;

mylaptop.RAM = 16;

mylaptop.SD = 300;

mylaptop.print();

// preobrasovanie dannõh

// Ex3:

// avtomatitseskoe preobrasovanie - done by compilator

// bolee malenkii typ dannõh prisvoivaetsa k bolsomu

double b;

int a = 7;

b = a; // automatic conversion

double d = 5.5;

double c = a + d; // automatic conversion


// preobrasovanie dannõh programmistom

// nusno kogda bolee bolsoe dyp dannõh prisvaevatsa malenkomu

// vosmosna poterja dannõh

int u;

double v = 7.8;

u = (int)v; // isklutsenie C++, worning not error


// typitsnoe situatsia osibok

double sredneje;

int kolitsestvo = 2;

int stsotsik = 9;

sredneje = stsotsik / kolitsestvo; // resultat 4.0

sredneje = (double)stsotsik / kolitsestvo; // resultat 4.5



Console.Read();

}

}

}


Download 24.57 Kb.

Bosh sahifa
Aloqalar

    Bosh sahifa


Sreda, tsetverg, pjatnitsa }

Download 24.57 Kb.