2017.06.23 23:00
2017.06.23 23:01
어떻게 고쳐야 하나요?
2017.06.25 21:10
total 은 배열이 아닙니다. type은 배열이구요...
compare 함수 안에 원인이 있습니다. 잘 찾아 보세요~
2017.07.01 00:46
아 감사합니다. 고쳤습니다.
2018.06.15 15:33
어떤 문제가 있나요?
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int NOS,forfor1,forfor2,Number1candidatepreferencesum=0,Number2candidatepreferencesum=0,Number3candidatepreferencesum=0,HO=0;
int a,b,c;
int Number1candidatepreference[3]={0, },Number2candidatepreference[3]={0, },Number3candidatepreference[3]={0, };
scanf("%d",&NOS);
for(forfor1=0;forfor1<NOS;forfor1++)
{
scanf("%d %d %d",&a,&b,&c);
for(forfor2=0;forfor2<3;forfor2++)
{
if(forfor2==0)
{
Number1candidatepreferencesum=Number1candidatepreferencesum+a;
Number1candidatepreference[a]++;
}
else if(forfor2==1)
{
Number2candidatepreferencesum=Number2candidatepreferencesum+b;
Number2candidatepreference[b]++;
}
else if(forfor2==2)
{
Number3candidatepreferencesum=Number3candidatepreferencesum+c;
Number3candidatepreference[c]++;
}
}
}
if(Number1candidatepreferencesum>Number2candidatepreferencesum)
{
if(Number1candidatepreferencesum>Number3candidatepreferencesum)
printf("1 %d",Number1candidatepreferencesum);
else if(Number1candidatepreferencesum<Number3candidatepreferencesum)
printf("3 %d",Number3candidatepreferencesum);
}
else if(Number1candidatepreferencesum<Number2candidatepreferencesum)
{
if(Number2candidatepreferencesum>Number3candidatepreferencesum)
printf("2 %d",Number1candidatepreferencesum);
else if(Number2candidatepreferencesum<Number3candidatepreferencesum)
printf("3 %d",Number3candidatepreferencesum);
}
else
{
for(forfor1=2;forfor1>=0;forfor1--)
{
if(Number1candidatepreference[forfor1]>Number2candidatepreference[forfor1])
{
if(Number1candidatepreference[forfor1]>Number3candidatepreference[forfor1]){
printf("1 %d",Number1candidatepreference[forfor1]);
HO=1;
}
else if(Number1candidatepreference[forfor1]<Number3candidatepreference[forfor1]){
printf("3 %d",Number3candidatepreference[forfor1]);
HO=1;
}
}
else if(Number1candidatepreference[forfor1]<Number2candidatepreference[forfor1])
{
if(Number2candidatepreference[forfor1]>Number3candidatepreference[forfor1]){
printf("2 %d",Number1candidatepreference[forfor1]);
HO=1;
}
else if(Number2candidatepreference[forfor1]<Number3candidatepreference[forfor1]){
printf("3 %d",Number3candidatepreference[forfor1]);
HO=1;
}
}
}
}
if(HO=0)
{
if(Number1candidatepreferencesum>Number2candidatepreferencesum)
{
if(Number1candidatepreferencesum>Number3candidatepreferencesum)
printf("0 %d",Number1candidatepreferencesum);
else if(Number1candidatepreferencesum<Number3candidatepreferencesum)
printf("0 %d",Number3candidatepreferencesum);
}
else if(Number1candidatepreferencesum<Number2candidatepreferencesum)
{
if(Number2candidatepreferencesum>Number3candidatepreferencesum)
printf("0 %d",Number1candidatepreferencesum);
else if(Number2candidatepreferencesum<Number3candidatepreferencesum)
printf("0 %d",Number3candidatepreferencesum);
}
}
return 0;
}
2019.03.19 22:32
변수 이름의 길이를 줄이면 고치기 쉽겠네요.