Usuario
necesito ayuda lo antes posible

Pregunta
-
tengo este programa y necesito que los resultados de guarda en el txt los pueda modificar y que cuando los modifique pueda verse cuando se vuelva a ejecutar
tambien se necesita que mediante lo que esta en el txt se puedan hacer las operaciones basicas con arreglo(suma de columna y fila, promedio por fila, columna y en general
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Votos
{
class Program
{
void Pedir(string []x )
{
for (int i = 0; i <x.Length; i++)
{
Console.WriteLine("Ingresa el nombre " + (i+1));
x[i] =Convert.ToString(Console.ReadLine());
}
}
void Llenar(int[,] v, String []p, String[]m)
{
for (int i = 0; i < v.GetLength(0); i++)
{
Console.WriteLine("Municipios " + m[i]+" ");
for (int j = 0;j < v.GetLength(1); j++)
{
Console.WriteLine("Partido " + p[j] + " ");
v[i, j] = int.Parse(Console.ReadLine());
}
Console.WriteLine("********************************************");
}
}
void Imprimir(int[,] v, String[] p, String[] m)
{
int suma = 0;
for (int i = 0; i < v.GetLength(0); i++)
Console.Write(m[i] + "\t");
for (int i = 0; i < v.GetLength(1); i++)
{
Console.WriteLine();
Console.WriteLine(p[i] + "\t");
for (int j = 0; j < v.GetLength(0); j++)
{
Console.Write(v[i,j]+"\t");
suma += v[i, j];
}
}
using (StreamWriter politicos = new StreamWriter("VOTOS.txt", false))
{
for (int i = 0; i < v.GetLength(0); i++)
{
for (int j = 0; j < v.GetLength(1); j++)
{
politicos.Write(v[i, j]);
}
}
}
Console.WriteLine("\n*************************************");
Console.WriteLine("Total de votos "+ suma);
}
void Resultados(int[,] v)
{
int Total = 0;
int[] tem = { 0, 0, 0, 0 };
for (int i = 0; i < v.GetLength(0); i++)
{
for (int j = 0; j < v.GetLength(1); j++)
{
Total += v[i, j];
}
}
for (int i = 0; i < v.GetLength(0); i++)
{
for (int j = 0; j < v.GetLength(1); j++)
{
//Console.Write(v[i, j] * 100 / Total + "%\t");
tem[j]+=((v[i,j]+100/Total));
}
Console.WriteLine();
}
for (int i = 0; i < v.GetLength(0); i++)
{
Console.Write(tem[i]*100/Total + " %\t");
}
Console.WriteLine("\n************************************************");
}
void Ganador(int[,] v, String[] p, String[] m)
{
float suma_votos = 0;
float[] suma = new float[4];
float[] porcentaje = new float[4];
for (int i = 0; i < v.GetLength(0); i++)
{
for (int j = 0; j < v.GetLength(1); j++)
{
suma[i] += v[i, j];
}
}
for (int i = 0; i < suma.Length; i++)
{
suma_votos += suma[i];
}
for (int i = 0; i < suma.Length; i++)
{
porcentaje[i] = (suma[i] / suma_votos) * 100;
}
for (int i = 0; i < suma.Length; i++)
{
Console.WriteLine(p[i] + " tiene un total de " + suma[i] + " votos ademas cuenta con el " + porcentaje[i] + " porciento de votos con ");
if (porcentaje[i] > 50)
{
Console.WriteLine("El partido politico " + p[i] + " ha conseguido mas de el 50 por cieno de votos, por lo tanto es el ganado");
}
}
for (int z = 0; z < suma.Length - 1; z++)
{
for (int j = 0; j < suma.Length - 1; j++)
{
if (suma[j] > suma[j + 1])
{
float temp = suma[j];
suma[j] = suma[j + 1];
suma[j + 1] = suma[j + 1];
suma[j + 1] = temp;
}
}
}
}
static void Main(string[] args)
{
int [,]votos;
String []partidos;
String[] municipios;
Program p = new Program();
Console.WriteLine("Bienvenidos al conteo de votos de las elecciones para Gobernador del Estado de México ");
Console.WriteLine("Dame la de Partios Politicos ");
int a = int.Parse(Console.ReadLine());
partidos = new string[a];
Console.WriteLine("Dame la cantidad de Municipios que participaron ");
int b = int.Parse(Console.ReadLine());
municipios = new string[b];
Console.WriteLine("Partidos Politicos");
p.Pedir(partidos);
Console.WriteLine("Municipios");
p.Pedir(municipios);
votos = new int[a, b];
Console.WriteLine("Ingresa los resultados");
p.Llenar(votos, partidos, municipios);
Console.WriteLine("Los resultados son ");
p.Imprimir(votos,partidos,municipios);
Console.WriteLine("El porcentaje de cada partido es ");
p.Resultados(votos);
p.Ganador(votos, partidos, municipios);
Console.ReadKey();
}
}
}