Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.73 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace aplicatiecuvectori
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         int n, sp = 0, ci=0, i=1, contor = 0;
  16.         int[] V = new int[100];
  17.        
  18.  
  19.         public Form1()
  20.         {
  21.             InitializeComponent();
  22.         }
  23.  
  24.        
  25.  
  26.         private void label1_Click(object sender, EventArgs e)
  27.         {
  28.         }
  29.  
  30.        
  31.  
  32.         private void label2_Click(object sender, EventArgs e)
  33.         {
  34.         }
  35.  
  36.         private void button1_Click(object sender, EventArgs e)
  37.         {
  38.             n = int.Parse(textBox1.Text);
  39.             textBox1.Text = " ";
  40.         }
  41.  
  42.         private void button2_Click(object sender, EventArgs e)
  43.         {
  44.             if (n >= i)
  45.             {
  46.                 V[i] = int.Parse(textBox2.Text);
  47.                 i++;
  48.                 richTextBox1.Text = richTextBox1.Text + " " + textBox2.Text;
  49.  
  50.  
  51.                
  52.  
  53.                 textBox2.Text = " ";
  54.             }
  55.             else textBox2.Enabled = false;
  56.            
  57.         }
  58.  
  59.         private void button3_Click(object sender, EventArgs e)
  60.         {
  61.             for (i = 1; i <= n; i++)
  62.             {
  63.                 if (V[i] % 2 != 0)
  64.                     ci++;
  65.             }
  66.             textBox3.Text = ci.ToString();
  67.         }
  68.  
  69.         private void button4_Click(object sender, EventArgs e)
  70.         {
  71.             for (i = 1; i <= n; i++)
  72.                 if (V[i] % 2 == 0)
  73.                     sp = sp + V[i];
  74.             textBox4.Text = sp.ToString();
  75.         }
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement