ODDAVG - Напишите программу для приема целых чисел с клавиатуры и найдите среднее значение из 10 нечетных чисел. Если введено четное целое число, проигнорируйте число в ваших расчетах и напечатайте сообщение «Нечетные числа только пожалуйста». Я хочу помочь с этой программой, я пробую ее более одного часа?C++ нечетный Средний
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
void Pause()
{ // function to freeze the screen, waiting for a `keypress`
string junk;
cout << "\n\n Press enter to continue...";
cin.ignore();
getline (cin,junk);
// void functions do not return a value
}
int main()
{
int even=0;
int odd=0;
int number=0;
int eventotal = 0;
int oddtotal = 0;
int counter = 0;
bool done;
int i;
// get `inpot`
cout << "Please enter 10 odd integers: " << endl << endl;
cin >> number;
cout << endl;
// display results
if ((number%2 == 0) && (number > 0))
{
cout << "odd numbers only please." << endl;
}
else if ((number > 0) && (i++))
{
odd++;
oddtotal = oddtotal +number;
}
while (number!=0)(!done);
counter ==10;
counter++;
int oddavg ;// to store the average of odd numbers
if(oddtotal!=0)
{
oddavg = oddtotal/ odd;
}
cout << " The average is: " << oddavg << endl;
// freeze screen
Pause();
return (0);
}
Вы явно скопировали его откуда-то. Он даже не компилируется со всеми «' »в коде. Что ты уже испробовал ? – Arunmu
Что такое 'while (number! = 0) (! Done);' предполагается делать? –
Положите код, который компилируется .. –