/* slumptal för toss_up_stater */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define IO 6
#define OH 18
#define NC 15
#define GA 16
#define FL 29
#define ME 4
#define NE 5
#define N 100
#define BIG 100
int main()
{
int a[N], i,j;
srand(time(NULL));
for(i=0; i < N; i++) a[i] = rand()%BIG;
int blue_sum=0, red_sum=0;
for(j=0; j< 90; j+=7)
{
int blue=0, red=0;
if (a[0+j]>50) blue=blue+IO; else red=red+IO;
if (a[1+j]>50) blue=blue+OH; else red=red+OH;
if (a[2+j]>50) blue=blue+NC; else red=red+NC;
if (a[3+j]>50) blue=blue+GA; else red=red+GA;
if (a[4+j]>50) blue=blue+FL; else red=red+FL;
if (a[5+j]>50) blue=blue+ME; else red=red+ME;
if (a[6+j]>50) blue=blue+NE; else red=red+NE;
printf("Blåa laget(DEM) får: %d ", blue);
printf(" Röda laget(REP) får: %d ", red);
printf("\n");
blue_sum=blue_sum+blue; red_sum=red_sum+red;
}
printf("Blåa totalt får: %d ", blue_sum);
printf(" Röda totalt får: %d ", red_sum);
printf("\n Är detta slump? \n");
return 0;
}
/* slumptal för toss_up_stater */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define IO 6
#define OH 18
#define NC 15
#define GA 16
#define FL 29
#define ME 4
#define NE 5
#define N 100
#define BIG 100
int main()
{
int a[N], i,j;
srand(time(NULL));
for(i=0; i < N; i++) a[i] = rand()%BIG;
int blue_sum=0, red_sum=0;
for(j=0; j< 90; j+=7)
{
int blue=0, red=0;
if (a[0+j]>50) blue=blue+IO; else red=red+IO;
if (a[1+j]>50) blue=blue+OH; else red=red+OH;
if (a[2+j]>50) blue=blue+NC; else red=red+NC;
if (a[3+j]>50) blue=blue+GA; else red=red+GA;
if (a[4+j]>50) blue=blue+FL; else red=red+FL;
if (a[5+j]>50) blue=blue+ME; else red=red+ME;
if (a[6+j]>50) blue=blue+NE; else red=red+NE;
printf("Blåa laget(DEM) får: %d ", blue);
printf(" Röda laget(REP) får: %d ", red);
printf("\n");
blue_sum=blue_sum+blue; red_sum=red_sum+red;
}
printf("Blåa totalt får: %d ", blue_sum);
printf(" Röda totalt får: %d ", red_sum);
printf("\n Är detta slump? \n");
return 0;
}
/* Slumptal för toss_up_stater 2020 */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/* Dessa delstater har olika antal elektorer tex IO (Iowa) har 6 */
#define IO 6
#define OH 18
#define NC 15
#define GA 16
#define FL 29
#define ME 4
#define NE 5
/* Vi skapar 140 slumptal och räknar med promille */
#define N 140
#define PROMILLE 1000
#define LIKA 500
int main()
{
int a[N], i,j;
srand(time(NULL)); /* krävs för att få nya slumptal varje körning */
for(i=0; i < N; i++) a[i] = rand()%PROMILLE; /* slumptalen samlas i a[0]...a[139] */
/* Det är vanligast på nätet att Demokrater är blå och Republikaner röda */
int blue_sum=0, red_sum=0, blue_mv=0, red_mv=0;
for(j=0; j< 140; j+=7) /* Alla delstater får eget slumptal & sen stegar man med 7 */
{
int blue=0, red=0;
if (a[0+j]>LIKA) blue=blue+IO; else red=red+IO;
if (a[1+j]>LIKA) blue=blue+OH; else red=red+OH;
if (a[2+j]>LIKA) blue=blue+NC; else red=red+NC;
if (a[3+j]>LIKA) blue=blue+GA; else red=red+GA;
if (a[4+j]>LIKA) blue=blue+FL; else red=red+FL;
if (a[5+j]>LIKA) blue=blue+ME; else red=red+ME;
if (a[6+j]>LIKA) blue=blue+NE; else red=red+NE;
printf("Blåa laget(DEM) får: %d ", blue);
printf(" Röda laget(REP) får: %d ", red);
printf("\n");
blue_sum=blue_sum+blue; red_sum=red_sum+red;
}
blue_mv=blue_sum/20;
red_mv=red_sum/20;
printf("Blåa medelvärdet: %d ", blue_mv);
printf(" Röda medelvärdet: %d ", red_mv);
printf("\n Är detta slump? \n");
return 0;
}
/* Slumptal för toss_up_stater 2020 */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/* Dessa delstater har olika antal elektorer tex IO (Iowa) har 6 */
#define IO 6
#define OH 18
#define NC 15
#define GA 16
#define FL 29
#define ME 4
#define NE 5
/* Vi skapar 140 slumptal och räknar med promille */
#define N 140
#define PROMILLE 1000
#define LIKA 500
int main()
{
int a[N], i,j;
srand(time(NULL)); /* krävs för att få nya slumptal varje körning */
for(i=0; i < N; i++) a[i] = rand()%PROMILLE; /* slumptalen samlas i a[0]...a[139] */
/* Det är vanligast på nätet att Demokrater är blå och Republikaner röda */
int blue_sum=0, red_sum=0, blue_mv=0, red_mv=0;
for(j=0; j< 140; j+=7) /* Alla delstater får eget slumptal & sen stegar man med 7 */
{
int blue=0, red=0;
if (a[0+j]>LIKA) blue=blue+IO; else red=red+IO;
if (a[1+j]>LIKA) blue=blue+OH; else red=red+OH;
if (a[2+j]>LIKA) blue=blue+NC; else red=red+NC;
if (a[3+j]>LIKA) blue=blue+GA; else red=red+GA;
if (a[4+j]>LIKA) blue=blue+FL; else red=red+FL;
if (a[5+j]>LIKA) blue=blue+ME; else red=red+ME;
if (a[6+j]>LIKA) blue=blue+NE; else red=red+NE;
printf("Blåa laget(DEM) får: %d ", blue);
printf(" Röda laget(REP) får: %d ", red);
printf("\n");
blue_sum=blue_sum+blue; red_sum=red_sum+red;
}
blue_mv=blue_sum/20;
red_mv=red_sum/20;
printf("Blåa medelvärdet: %d ", blue_mv);
printf(" Röda medelvärdet: %d ", red_mv);
printf("\n Är detta slump? \n");
return 0;
}
for (int i = 0; i < N; i++)
/* Slumptal för toss_up_stater 2020 */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/* Dessa delstater har olika antal elektorer tex IO (Iowa) har 6 */
#define IO 6
#define OH 18
#define NC 15
#define GA 16
#define FL 29
#define ME 4
#define NE 5
/* Vi skapar 140 slumptal och räknar med promille */
#define N 140
#define PROMILLE 1000
#define LIKA 500
int main()
{
int a[N], i,j;
srand(time(NULL)); /* krävs för att få nya slumptal varje körning */
for(i=0; i < N; i++) a[i] = rand()%PROMILLE; /* slumptalen samlas i a[0]...a[139] */
/* Det är vanligast på nätet att Demokrater är blå och Republikaner röda */
int blue_sum=0, red_sum=0, blue_mv=0, red_mv=0;
for(j=0; j< 140; j+=7) /* Alla delstater får eget slumptal & sen stegar man med 7 */
{
int blue=0, red=0;
if (a[0+j]>LIKA) blue=blue+IO; else red=red+IO;
if (a[1+j]>LIKA) blue=blue+OH; else red=red+OH;
if (a[2+j]>LIKA) blue=blue+NC; else red=red+NC;
if (a[3+j]>LIKA) blue=blue+GA; else red=red+GA;
if (a[4+j]>LIKA) blue=blue+FL; else red=red+FL;
if (a[5+j]>LIKA) blue=blue+ME; else red=red+ME;
if (a[6+j]>LIKA) blue=blue+NE; else red=red+NE;
printf("Blåa laget(DEM) får: %d ", blue);
printf(" Röda laget(REP) får: %d ", red);
printf("\n");
blue_sum=blue_sum+blue; red_sum=red_sum+red;
}
blue_mv=blue_sum/20;
red_mv=red_sum/20;
printf("Blåa medelvärdet: %d ", blue_mv);
printf(" Röda medelvärdet: %d ", red_mv);
printf("\n Är detta slump? \n");
return 0;
}
Du måste vara medlem för att kunna kommentera