CSES - Datatähti 2023 alku - Results
Submission details
Task:Lehmät
Sender:fatihmerickoc
Submission time:2022-11-05 23:07:10 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:9:37: warning: right operand of comma operator has no effect [-Wunused-value]
    9 |     cin >> lineNumber , heightnumber;
      |                                     ^
input/code.cpp:22:21: error: 'i' was not declared in this scope
   22 |         if(sequence[i] == 1)
      |                     ^

Code

#include <bits/stdc++.h>
using namespace std;
 
int main()
{ 


    int lineNumber , heightnumber;
    cin >> lineNumber , heightnumber;
    int sequence[lineNumber];
    int inekSayisi = 7;
    string das;
    // count the frequency

    for (int i = 0; i < lineNumber; ++i)
    {
        cin >> inekSayisi;
    }
    int arraySize = sizeof(sequence)/sizeof(sequence[0]);
 //   for (int i = 0; i < arraySize; i++)
    {
        if(sequence[i] == 1)
        {
            for (int f = 1; f < arraySize-i; f++)
            {
                if (sequence[i+f] == 2)
                {
                    inekSayisi++;
                }else if (sequence[i+f] == 1)
                {
                    break;
                }
        
            }
           
        }
    }
    cout << inekSayisi << endl;
    return 0;
}