Home > Back-end >  C language structure
C language structure

Time:01-04

#include
Int main ()
{
Printf (" welcome to vote \ n ");
printf("\n");
Printf (" candidates are: y, w, e, r ");
Struct piao
{
Int y;
int w;
Int e;
Int r;
} piao1=,0,0,0 {0};

int i,j;
Char a, b, c, d, t;
B='y'
C='w';
D='e';
T='r'.
for(i=0; i<10; I++)
{
printf("\n");
Printf (" please input your support players: ");
The scanf (" % s ", & amp; a);
getchar();
If (0)
{
}
If (b==a)
Piao1. Y=piao1. Y + 1;
If (c==a)
Piao1. W=piao1. W + 1;
If (d==a)
Piao1. E=piao1. E + 1;
If (t==a)
Piao1. R=piao1. R + 1;
}
Printf (" \ n y votes: % d ", piao1. Y);
Printf (" \ n w votes: % d ", piao1. W);
Printf (" e votes: % d \ n ", piao1. E);
Printf (" r votes: % d \ n ", piao1. R);

If (piao1. Y> Piao1. W& & Piao1. Y> Piao1. E& & Piao1. Y> Piao1. R)
Printf (" the winner is: y \ n ");
If (piao1. W> Piao1. Y& & Piao1. W> Piao1. E& & Piao1. W> Piao1. R)
Printf (" the winner is: w \ n ");
If (piao1. E> Piao1. Y& & Piao1. E> Piao1. W& & Piao1. E> Piao1. R)
Printf (" the winner is: e \ n ");
If (piao1. R> Piao1. Y& & Piao1. R> Piao1. W& & Piao1. R> Piao1. E)
Printf (" the winner is: r \ n ");
}
Why I write this source of structure of the y variable how to a maximum of 1?

CodePudding user response:

How to change all make uncertain

CodePudding user response:

The % s to % c

CodePudding user response:


Change good, remember to play enjoy oh, and I remember the for loop specification writing, write the {}

CodePudding user response:

 # include 

Int main ()
{
Printf (" welcome to vote \ n ");
printf("\n");
Printf (" candidates are: y, w, e, r ");
Struct piao
{
Int y;
int w;
Int e;
Int r;
} piao1=,0,0,0 {0};

int i,j;
Char a, b, c, d, t;
B='y'
C='w';
D='e';
T='r'.
for(i=0; i<10; I++)
{
printf("\n");
Printf (" please input your support players: ");
//the scanf (" % s ", & amp; a);
The scanf (" % c ", & amp; a);
getchar();
/*
If (0)
{
}
*/
If (b==a)
Piao1. Y=piao1. Y + 1;
If (c==a)
Piao1. W=piao1. W + 1;
If (d==a)
Piao1. E=piao1. E + 1;
If (t==a)
Piao1. R=piao1. R + 1;
}
Printf (" \ n y votes: % d ", piao1. Y);
Printf (" \ n w votes: % d ", piao1. W);
Printf (" e votes: % d \ n ", piao1. E);
Printf (" r votes: % d \ n ", piao1. R);

If (piao1. Y> Piao1. W& & Piao1. Y> Piao1. E& & Piao1. Y> Piao1. R)
Printf (" the winner is: y \ n ");
If (piao1. W> Piao1. Y& & Piao1. W> Piao1. E& & Piao1. W> Piao1. R)
Printf (" the winner is: w \ n ");
If (piao1. E> Piao1. Y& & Piao1. E> Piao1. W& & Piao1. E> Piao1. R)
Printf (" the winner is: e \ n ");
If (piao1. R> Piao1. Y& & Piao1. R> Piao1. W& & Piao1. R> Piao1. E)
Printf (" the winner is: r \ n ");
}

For your reference ~
  • Related