Pavle_nis

Untitled

Mar 1st, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.49 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 WindowsFormsApp12
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.        
  20.         private void btn1_Click(object sender, EventArgs e)
  21.         {
  22.             int n = txtUnos.Text.Trim().Length;
  23.  
  24.             if (n > 25)
  25.             {
  26.                 MessageBox.Show("Unesi manje!");
  27.                 return;
  28.             }
  29.             else
  30.             {
  31.                 char[,] niz = new char[n, n];
  32.                 int k = 0;
  33.                 string str = "";
  34.                 char pom = ' ';
  35.                 int count = 0, zbir1 = 0, zbir2 = 0;
  36.                 List<char> lista1 = new List<char>();
  37.                 List<char> lista2 = new List<char>();
  38.  
  39.                 for (int i = 0; i < n; i++)
  40.                 {
  41.                     for (int j = 0; j < n; j++)
  42.                     {
  43.                         if (Convert.ToInt32(txtUnos.Text[j]) + k > 90)
  44.                         {
  45.                             niz[i, j] = Convert.ToChar((Convert.ToInt32(txtUnos.Text[j]) + k) - 26);
  46.                         }
  47.                         else
  48.                         {
  49.                             niz[i, j] = Convert.ToChar(Convert.ToInt32(txtUnos.Text[j]) + k);
  50.                         }
  51.                         str += niz[i, j].ToString() + " ";
  52.                     }
  53.                     k++;
  54.                     str += "\n";
  55.                 }
  56.  
  57.                 richTextBox1.Text = str;
  58.  
  59.                 for(int i = 0; i < n - 1; i++)
  60.                 {
  61.                     for (int j = 0; j < n; j++)
  62.                     {
  63.                         if (i == j)
  64.                         {
  65.                             if (niz[i, j] == niz[i + 1, j + 1])
  66.                             {
  67.                                 MessageBox.Show(niz[i, j].ToString());
  68.                             }
  69.                         }
  70.                         if (i + j == n - 1)
  71.                         {
  72.                             if (niz[i, j] == niz[i + 1, j - 1])
  73.                             {
  74.                                 MessageBox.Show(niz[i, j].ToString());
  75.                             }
  76.                         }
  77.                     }
  78.                 }
  79.             }
  80.         }
  81.     }
  82. }
Add Comment
Please, Sign In to add comment