Author Topic: Newbie programmer in need over a pain in the ass error!  (Read 405 times)

Offline alexfromhell1

  • Single posting newcomer
  • *
  • Posts: 1
Newbie programmer in need over a pain in the ass error!
« on: January 16, 2019, 01:41:11 am »
I need your help pro programmers! I have an error that i can't easily resolve...
if i don't add:

std::vector<char>

then i get this message:
incompatible types of assignment of char to char[40]

if i do however type it then i get this:

two or more data types in declaration of 'main'...

here is the code:

#include <iostream>
#include <math.h>
#include <conio.h>
#include <stdio.h>
#include <vector>

using namespace std;
std::vector<char>


int main()
{
    int n,i,nvm,nvz,ntm,ntz;
    float v[40],t[40],svm,svz,stm,stz,pvm,pvz,ptm,ptz,mtm,mtz,mvm,mvz;
    char p[40] {'M','m','Z','z','\0'};
    cout << "Unesite broj ucenika u odeljenju: ";
    cin >> n;
    for(i=1;i<=n;i++)
    {
        cout << "Unesite pol ucenika (M ili Z): ";
        cin >> p;
        cout << "Unesite visine ucenika: ";
        cin >> v;
        cout << "Unesite tezine ucenika: ";
        cin >> t;
    }
    svm = 0;
    nvm = 0;
    for(i=1;i<=n;i++)
        if((p = 'M') || (p = 'm'))
            svm+=v;
    for(i=1;i<=n;i++)
        if((p = 'M') || (p = 'm'))
            nvm+=1;

    pvm = svm/nvm;
    cout << "Prosecna visina muskih ucenika je:" << pvm <<"\n";
    svz = 0;
    nvz = 0;
    for(i=1;i<=n;i++)
        if((p = 'Z') || (p = 'z'))
            svz+=v;
    for(i=1;i<=n;i++)
        if((p = 'Z') || (p = 'z'))
            nvz+=1;

    pvz = svz/nvz;
    cout << "Prosecna visina zenskih ucenika je:" << pvz <<"\n";
     stm = 0;
     ntm = 0;
    for(i=1;i<=n;i++)
        if((p = 'M') || (p = 'm'))
             stm+=t;
    for(i=1;i<=n;i++)
        if((p = 'M') || (p = 'm'))
             ntm+=1;

    ptm = stm/ntm;
    cout << "Prosecna tezina muskih ucenika je:" << ptm <<"\n";
    stz = 0;
    ntz = 0;
    for(i=1;i<=n;i++)
        if((p = 'Z') || (p = 'z'))
            stz+=t;
    for(i=1;i<=n;i++)
        if((p = 'Z') || (p = 'z'))
            ntz+=1;

    ptz = stz/ntz;
    cout << "Prosecna tezina zenskih ucenika je:" << ptz <<"\n";
    mvm = v[1];
    for(i=2;i<=n;i++)
        if(((v > mvm) && ((p = 'M') || (p = 'm'))))
         mvm = v;
    cout <<" Maksimalna visina muskaraca je: " <<mvm <<"\n";
    mvz = v[1];
    for(i=2;i<=n;i++)
        if(((v > mvz) && ((p = 'Z') || (p = 'z'))))
         mvz = v;
    cout <<" Maksimalna visina zena je: " <<mvz <<"\n";
    mtm = t[1];
    for(i=2;i<=n;i++)
        if(((t > mtm)) && ((p = 'M') || (p = 'm')))
         mtm = t;
    cout <<" Maksimalna tezina muskaraca je: " <<mtm <<"\n";
    mtz = t[1];
    for(i=2;i<=n;i++)
        if(((t > mtz) && ((p = 'Z') || (p = 'z'))))
         mtz = t;
    cout <<" Maksimalna tezina zena je: " <<mtz <<"\n";
    getch();
    return 0;
}

Offline sodev

  • Regular
  • ***
  • Posts: 261
Re: Newbie programmer in need over a pain in the ass error!
« Reply #1 on: January 16, 2019, 02:51:56 am »
I dont see a CodeBlocks problem here, i see a code obfuscation homework here. No one can help you here, go to a website that teaches you the basics of c++

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6512
    • My Best Post
Re: Newbie programmer in need over a pain in the ass error!
« Reply #2 on: January 16, 2019, 03:46:06 am »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org