Monday, November 30, 2015

Dynamically populating Grid View

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

public partial class _Default : System.Web.UI.Page
{
    SqlConnection s1;
    protected void Page_Load(object sender, EventArgs e)
    {
        string ss = @"Data Source=VMB-PC\SQLEXPRESS;Initial Catalog=website;Integrated Security=True";
        s1 = new SqlConnection(ss);
        try
        {
            s1.Open();
            DataTable dt = new DataTable();
            dt.Columns.AddRange(new DataColumn[5] { new DataColumn("Rollno", typeof(int)),
                            new DataColumn("Name", typeof(string)),
                            new DataColumn("Department",typeof(string)),
            new DataColumn("Batch",typeof(string)),
            new DataColumn("Section",typeof(string))});
            dt.Rows.Add(1, "h", "a", "s","c");
            GridView1.DataSource = dt;
            GridView1.DataBind();

        }
        catch (Exception excep)
        {
           
        }
    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string s = GridView1.SelectedRow.Cells[1].Text;
        Label1.Text = s;

    }
}










<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
    </div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateSelectButton="True" CellPadding="4" ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
            <AlternatingRowStyle BackColor="White" />
            <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
            <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
            <SortedAscendingCellStyle BackColor="#FDF5AC" />
            <SortedAscendingHeaderStyle BackColor="#4D0000" />
            <SortedDescendingCellStyle BackColor="#FCF6C0" />
            <SortedDescendingHeaderStyle BackColor="#820000" />
        </asp:GridView>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </form>
    </body>
</html>

Thursday, November 26, 2015

Dynamically populating DropDown List in asp.net C#

string ss = @"Data Source=VMB-PC\SQLEXPRESS;Initial Catalog=website;Integrated Security=True";
        s = new SqlConnection(ss);
     
        s.Open();
        SqlCommand cmd = new SqlCommand("select *from departments",s);
        SqlDataReader d = cmd.ExecuteReader();
        for (int i = 0; d.Read(); i++)
        {

            DropDownList1.Items.Insert(i, d.GetString(0));
        }

Disable BACK button in asp.net c#

  1. <head>
  2. <script type ="text/javascript">  
  3.   
  4.     window.onload = window.history.forward(0);  
  5.     
  6. </script>

  1. </head>

Tuesday, November 24, 2015

Creating Alert In Asp.net C#

protected void but1(object sender, EventArgs e)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        sb.Append("<script type = 'text/javascript'>");
        sb.Append("window.onload=function(){");
        sb.Append("alert('");
        sb.Append("Message to be displayed");
        sb.Append("')};");
        sb.Append("</script>");
        ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
     
    }

Sunday, August 23, 2015

Dynamic positioning (TEXT GROWING IN HTML) USING JS

<html>
<head>
<script>
var flag=1,fontsize=2;
function start()
{
setInterval("change()",100);
}
function change()
{
h.style.fontSize=fontsize;
h.innerText+=fontsize;
if(fontsize==500)
fontsize=0;

fontsize++;
if(flag==1)
{
document.body.style.backgroundColor="red";
flag=0;
}
else
{
document.body.style.backgroundColor="green";
flag=1;
}
}

</script>
</head>
<body onload="start()">
<p id="h">Hi Welcome</p>

</body>
</html>

Change the background color dynamically using java script

<html>
<head>
<script>

function start()
{
document.body.style.backgroundColor="red";
}

</script>
</head>
<body>
<p>Hi Welcome</p>
<input type="button" onclick="start()" value="Click me" >
</body>
</html>

Collections CHILDREN in html using JS

Collections: 
It is an array of all the elements(tags) that are present in the html page.

documemt.all==> Is a collection/array of all the elements in the html page in the order in which they appear on the html page..

documemt.all.length==>Is used to find out howmany elements/tags are there in the html page.

document.all[index].children==>Is an array/collection of all the immediate child-elements of the all[index] element.

document.all[index].children.length==>Is used to find out howmany elements/tags are there inside the all[index] element/tags.

<html>
<head>
<script>
var data=" THE TAGS ARE:";
function start()
{
for(var i=0;i<document.all.length;i++)
{
data+=" <br><br> TAG: "+document.all[i].tagName;
if(document.all[i].children.length>0)
data+="   <b> ITS CHILD : </b>";
for(var j=0;j<document.all[i].children.length;j++)
data+=" "+document.all[i].children[j].tagName;
}

para.innerHTML+=data;
}

</script>
</head>
<body>
<p id="para">Hi Welcome</p>
<input type="button" onclick="start()" value="Click me" >
</body>
</html>

COLLECTIONS IN HTML (Dynamic Object Model Using JS)

Collections: 
It is an array of all the elements(tags) that are present in the html page.

documemt.all==> Is a collection/array of all the elements in the html page in the order in which they appear on the html page..

documemt.all.length==>Is used to find out howmany elements/tags are there in the html page.

document.all[index].children==>Is an array/collection of all the immediate child-elements of the all[index] element.

document.all[index].children.length==>Is used to find out howmany elements/tags are there inside the all[index] element/tags.


<html>
<head>
<script>
var data=" THE TAGS ARE:";
function start()
{
for(var i=0;i<document.all.length;i++)
data+="  "+document.all[i].tagName;
para.innerText+=data;
}

</script>
</head>
<body>
<p id="para">Hi Welcome</p>
<input type="button" onclick="start()" value="Click me" >
</body>
</html>

Saturday, August 22, 2015

IMAGE SWITCHER Android Example

package com.example.vadivelanudayakumar.imageswitch;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;


public class MainActivity extends ActionBarActivity {

    int[] images={R.drawable.vv,R.drawable.browser,R.drawable.facebook,R.drawable.gmail,R.drawable.ln,R.drawable.gmaill,R.drawable.twitter,R.drawable.you};
    int counter=0;
    ImageView img;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        img=(ImageView)findViewById(R.id.imageView);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    public void next(View v){
 
    img.setImageResource(images[counter]);
        counter++;
        if(counter>=images.length)
            counter=0;
    }
}

Email In Android


    public void send(View v)
    {
        Intent i=new Intent(Intent.ACTION_SEND);
        i.putExtra(Intent.EXTRA_EMAIL,"vadivelan.1205237@srec.ac.in");
        i.putExtra(Intent.EXTRA_SUBJECT,"EMAIL SUBJECT");
        i.putExtra(Intent.EXTRA_TEXT,"EMAIL msg");
        i.setType("message/rfc822");
        startActivity(Intent.createChooser(i,"MAIL"));
        Toast.makeText(this.getApplicationContext(),"Sending",Toast.LENGTH_LONG);
    }

Tuesday, August 18, 2015

OTHER AVERAGE CALCULATION ALGORITHM

AVERAGE CALCULATION ALGORITHM


normally we calculate average as :

             x1+x2+.........+xn
avg =  ---------------------
                      n











MY ALGORITHM:


                      (xn-x1)+(xn-x2)+......(xn-x(n-1))                                           
avg = x1  +   -----------------------------------                                         
                                            n                                                                     

here, xn is the largest no.


THIS WORKS GOOD FOR 2nos
ie

102.75 and 103.6


traditional avg=(102.75+103.6)/2

BY THIS METHOD

avg=102.75 + (0.85/2) = 103.175

Friday, August 7, 2015

HOW TO AVOID CLICKS OR COPYING FROM A WEBPAGE

<html>
<head>
<script>
//TO PREVENT CLICKS
document.onmousedown=sia;function sia()
{
window.alert("Clicks Not Allowed");
}
</script>
</head>
<body bgcolor="#EAEAEA" ondragstart="return false" onselectstart="return false">




YOU CANNOT COPY THIS CONTENT
:-P


</body>
</html>

Tuesday, July 14, 2015

Vowels program in Java Script

<html xmlns="http://w3.org/1999/xhtml">
<head>
<script>
window.alert("Vowels PROGRAM");
var n=window.prompt("Enter alphabet :","");
document.write("<h1>VOWEL Program</h1><br>");
switch(n)
{
case "a":
case "e":
case "i":
case "o":
case "u":
document.write("<h2>It is a vowel.....</h2>");
break;
default:
document.write("<h2>It is not a vowel.....</h2>");
break;
}
</script>
</head>
<body>
</body>
</html>

Fibonacci series using java script

<html xmlns="http://w3.org/1999/xhtml">
<head>
<script>
window.alert("FIBONACCI NUMBER PROGRAM");
//converting the default string input to an integer value
var n=parseInt(window.prompt("Enter Number :","0"));
//variable declarations
var x=-1,y=1;
document.writeln("<h1>THE FIBONACCI SERIES FOR THE NUMBER "+n+" IS:</h1>");
for(var i=0;i<n;i++)
{
document.write(x+y+"<br>");
//without var temp works!!!!!
temp=x+y;
x=y;
y=temp;
}
</script>
</head>
<body>
</body>
</html>

Friday, July 3, 2015

C program to find the largest-sum (2*2)submatrix from a given n*n matrix




C program :

Copy the program to a notepad and save it as a .c file and open using turbo c++.




#include<stdio.h>
#include<conio.h>
void main()
{
int index[100][5]={0},a[5][5]={0},sum[100]={0},r,c,k=0,iv,jv,i,j,largest;
clrscr();
printf("Enter row and column value:");
scanf("%d%d",&r,&c);
printf("\nEnter the matrix\n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
if((i<=r-2)&&(j<=c-2))
{
index[k][0]=i;
index[k][1]=j;
sum[k]=a[i][j]+a[i+1][j]+a[i][j+1]+a[i+1][j+1];
//printf("(%d %d) %d",i,j,sum[k]);
k++;
}
}
}
largest=sum[0];
iv=index[0][0];
jv=index[0][1];
for(i=1;i<=k;i++)
{
if(largest<sum[i])
{
largest=sum[i];
iv=index[i][0];
jv=index[i][1];
}
}
printf("the largest sum (2*2)subset matrix is:\n %d %d\n %d %d",a[iv][jv],a[iv][jv+1],a[iv+1][jv],a[iv+1][jv+1]);

getch();
}

Saturday, June 20, 2015

Connecting Android App to live Server

Main Activity.java




package com.example.check;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;

import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView t=(TextView)findViewById(R.id.textView1);
new class2(t).execute();

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

}
class class2 extends AsyncTask<String, Void,String>
{

TextView tt;
class2(TextView t)
{
tt=t;
}
@Override
protected String doInBackground(String... arg0) {
// TODO Auto-generated method stub

String s="http://vadivelan.esy.es/new.php";
try {
URL u=new URL(s);
URLConnection c=u.openConnection();
c.setDoOutput(true);

OutputStreamWriter uu=new OutputStreamWriter(c.getOutputStream());

String data=URLEncoder.encode("hi","UTF-8")+"="+URLEncoder.encode("Data tobe Posted","UTF-8");

//data+="&"+URLEncoder.encode("hi","UTF-8")+"="+URLEncoder.encode("Data tobe Posted","UTF-8");

uu.write(data);

uu.flush();

BufferedReader r=new BufferedReader(new InputStreamReader(c.getInputStream()));

return r.readLine();


} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "ERROR";
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
tt.setText(result);
}

}









Activity Main.xml




<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="203dp"
        android:text="TextView" />
 
</RelativeLayout>








Android Manifest


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.check"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.check.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>







The PHP File on Server



<?php
$c=$_POST['hi'];
echo $c;

?>




Connect Android App to Sql Server ::

https://amitku.wordpress.com/2011/08/03/how-to-connect-and-access-sql-database-server-from-android-app/



Friday, April 3, 2015

Quick Match Cards game in c#

QuickMatch

Rules of QuickMatch

QuickMatch can be played as per the following rules:

n  It is a multi-player game. There can be 2 to 4 players.

n  Each player is given a set of five cards. The remaining cards are kept in a pile at the center.

n  The player can either draw a card from the pile of cards or pick a card, which is thrown by 
another player.

n  The first player to collect five cards of the same suite wins the game.



Instant play,download the game : click here


Design Specifications

The design of the game should be as per the following specifications:

n  It is a multi-player game. The number of players that can play the game can be 2 to 4.

n  The name of each player is accepted from the user before starting the game.

n  The cards are distributed to the players randomly. The remaining cards are kept in a pile at th
center.

n  The player whose name is entered first gets the first chance.

n  Other players get the chance in the sequence in which their names were entered.

n  The first player needs to pick the topmost card from the pile.

n  The card picked by the player gets added to his/her card collection. When a new card is added in the players card collection, the total number of cards in the collection exceeds five. Therefore, the player needs to discard a card from his/her collection and place it upturned so that the other players can see the card.

n  After the first player discards the card, the next player gets the chance to pick a card.
All players except the first player can either pick a card from the pile or pick the card that the previous player has discarded.


n  After a player discards a card, the players collection of cards should be checked to determine whether all cards belong to the same suite.









C# Code:


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

namespace ConsoleApplication9
{
    class user
    {
        public string name;
        public int[] cards=new int[5];
    }

   
    
    
    class Program
    {
        static string[] cardspack = new string[52];
        static bool[] flag = new bool[52];
    
        
        
        
        
        static int getcard()
        {
            int nn;
            Random r = new Random();
            while(true)
            {
            nn = (r.Next() % 52);
            if (flag[nn] == false)
                break;
            }
            flag[nn] = true;
             return nn;       
               
        }
        
        
        
        
        static void init()
        {
            for (int i = 0, j = 2; i < 52; i++)
            {
                flag[i] = false;
                string msg = "The ";
                if (i % 13 == 0)
                {
                    msg += "king ";
                    j = 2;
                }
                else if ((i - 1) % 13 == 0)
                    msg += "queen ";
                else if ((i - 2) % 13 == 0)
                    msg += "jack ";
                else if ((i - 3) % 13 == 0)
                    msg += "ace ";
                else
                {
                    msg += j.ToString() + " ";
                    j++;
                }
                if (i < 13)
                    msg += "spades ";
                else if (i < 26)
                    msg += "hearts ";
                else if (i < 39)
                    msg += "clubs ";
                else
                    msg += "diamonds ";
                cardspack[i] = msg;
                //Console.WriteLine(cardspack[i]+"  "+flag[i]);
            }
            
        }

        static void wait()
        {
            
            
            Console.ForegroundColor = ConsoleColor.Black;
            for (long i = 0; i < 1000; i++)
            {
                for (long ii = 0; ii < 10; ii++)
                {
                    Console.BackgroundColor = ConsoleColor.White;
                    Console.Write("10101000010000");
                } 
                for (long ii = 0; ii < 10; ii++)
                {
                    Console.BackgroundColor = ConsoleColor.Red;
                    Console.Write("10101000010000");
                } 
                }
            Console.Clear();
        }
        
        
        
        static int check(user u)
        {
            if (u.cards[0] < 13 && u.cards[1] < 13 && u.cards[2] < 13 && u.cards[3] < 13 && u.cards[4] < 13)
            {
                Console.BackgroundColor = ConsoleColor.Green;
                Console.Clear();
                Console.WriteLine("\n\n\n\n\t\t\t"+u.name+" WINS!!!!!!!!!!!!");
                return 1;
            }
            else if (u.cards[0] > 12 && u.cards[1] > 12 && u.cards[2] > 12 && u.cards[3] > 12 && u.cards[4] > 12 && u.cards[0] < 26 && u.cards[1] < 26 && u.cards[2] < 26 && u.cards[3] < 26 && u.cards[4] < 26)
            {
                Console.BackgroundColor = ConsoleColor.Green;
                Console.Clear();
                Console.WriteLine("\n\n\n\n\t\t\t"+u.name+" WINS!!!!!!!!!!!!");
                return 1;
            }
            else if (u.cards[0] > 25 && u.cards[1] > 25 && u.cards[2] > 25 && u.cards[3] > 25 && u.cards[4] > 25 && u.cards[0] < 39 && u.cards[1] < 39 && u.cards[2] < 39 && u.cards[3] < 39 && u.cards[4] < 39)
            {
                Console.BackgroundColor = ConsoleColor.Green;
                Console.Clear();
                Console.WriteLine("\n\n\n\n\t\t\t"+u.name+" WINS!!!!!!!!!!!!");
                return 1;
            }
            else if (u.cards[0] > 38 && u.cards[1] > 38 && u.cards[2] > 38 && u.cards[3] > 38 && u.cards[4] > 38)
            { 
                Console.BackgroundColor = ConsoleColor.Green;
                Console.Clear();
                Console.WriteLine("\n\n\n\n\t\t\t"+u.name+" WINS!!!!!!!!!!!!");
                return 1;
            }
        else
                return 0;
        }

        
        static void Main(string[] args)
        {
            Console.Title = "Vadivelan Udayakumar";
            wait();
            Console.CursorVisible = false;
            Console.BackgroundColor = ConsoleColor.Gray;
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("\n\n\n\n\n\n\n\n\n\t\t\t\tWelcome!!!!!!!!!\t\t\t\t");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("\n\n\t\t\t     Quick Match-Cards Game\t\t\t\t\t");
            Console.WriteLine("\n\n\t\t\t\t  Press any key\t\t\t\t\t");

           
            Console.ReadLine();
            wait();
            init();
            Console.BackgroundColor = ConsoleColor.White;
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Black;
            Console.WriteLine("\n\n\t\t\tQuick Match:::\n\n\tAbout game:\n\n\t * It is a multi-player game, there can be 2 to 4 players.\n\n\t * Each player is given a set of five cards.\n\n\t * The remaining cards are kept in a pile at the center.\n\n\t * The player can either draw a card from the pile of cards or pick a \n\t   card, which is thrown by another player.\n\n\t * The first player to collect five cards of the same suite wins the \n\t   game.\n\n\n\n\t\tPRESS ANY KEY TO START.....");
            Console.ReadLine();
            Console.BackgroundColor = ConsoleColor.Yellow;
            Console.Clear();
            Console.Title = "..............Quick Match...............By, Vadivelan.U and Parthiban.S";
            Console.CursorVisible = true;
            Console.Write("\n\n\tEnter the Number of players (Integer value):\n\n\t");
            int n = Convert.ToInt16(Console.ReadLine());
            user[] u = new user[n];

            Console.Clear();

            for (int i = 0; i < n; i++)
            {
                u[i] = new user();
                Console.Write("\n\n\t\t\tEnter player" + (i + 1) + "'s name (String Value): \n\n\t\t\t");
                u[i].name=Console.ReadLine();
                Console.Write("\n\n\n\t\t\tYour cards are:\n");
                for (int j = 0; j < 5;)
                {
                        int nn=getcard();               
                        
                        u[i].cards[j] = nn;
                        j++;
                        Console.Write("\n\n\t\t\t" + cardspack[nn]);
                   
                }
                Console.WriteLine("\n\n\t\t\tPress any key..");
                Console.ReadKey();
                Console.Clear();
            }


            wait();
            
            
            Console.WriteLine("Lets Start the game:");
            int left=-1;
            for (int i = 0; ;i++)
            {
                
                if (i % 2 == 0)
                {
                    Console.BackgroundColor = ConsoleColor.White;
                    Console.Clear();
                    Console.ForegroundColor = ConsoleColor.Black;
                }
                else
                    
                    {
                        Console.BackgroundColor = ConsoleColor.Blue;
                        Console.Clear();
                        Console.ForegroundColor = ConsoleColor.Black;
                    }
                Console.Title = "\n\t\tPlay : " + u[i].name;
                Console.WriteLine("\n\n\t\t" + u[i].name + "'s turn\n\n\t\tYour Cards are:");
                for (int j = 0; j < 5; j++)
                    Console.WriteLine("\t\t"+cardspack[u[i].cards[j]]);
                if(left!=-1)
                    Console.WriteLine("\nEnter n to take a new card from pile (or) m to take the dropped card(" + cardspack[left] + ") : ");
                else
                    Console.WriteLine("\n\t\tEnter n to take a new card from pile"); 
                char c = Convert.ToChar(Console.ReadLine());
                int newc=0;
                switch (c)
                {
                    case 'm':
                                   newc = left;
                                   Console.WriteLine("\n\n\t\tCard taken:" + cardspack[newc]);
                        
                        break;
        
                    case 'n':
                        newc = getcard();
                        Console.WriteLine("\n\n\t\tNew card:" + cardspack[newc]);
                            break;
                }


                Console.WriteLine("\n\t\tEnter the card to drop(1-5):");
                int k = Convert.ToInt16(Console.ReadLine());
                left=u[i].cards[(k-1)];
                flag[left]=false;
                u[i].cards[(k-1)]=newc;

                Console.WriteLine("\n\t\tYour new cards are:\n");

                for (int j = 0; j < 5; j++)
                    Console.WriteLine("\n\t\t"+cardspack[u[i].cards[j]]);

                int x=check(u[i]);
                if (x == 1)
                    break;
                Console.ReadLine();

                if ((i + 1) == n)
                        i = -1;
                Console.Clear();
            
            }





                Console.Read();
        }
    }
}







Instant play,download the game : click here