You are on page 1of 1

7.

Write a program that reads a number n, and an array of n numbers and computes whether there are
odd numbers inside the array

Sample:

INPUT OUTPUT
6
no
18 14 22 28 30 6

1. Descrierea algoritmului in limbajul 2. Programul C++


pseudocod (in Borland C)

start #include<iostream.h>
citeste n void main()
odd=0; {
pentru i = 1….n executa: int n, i, v[100], odd;
citeste v[i] for(i=1;i<=n;i++)
daca (v[i]%2==1) atunci odd=1 {cin>>v[i];
next i if(v[i]%2==1) odd=1;
daca (odd==1) atunci scrie ”yes” }
altfel scrie ”no” if(odd==1) cout<<”yes”;
sfarsit else cout<<”no”;
stop }

3. Programul C++
(in MinGW)

#include<iostream>
uses namespace std;
int main()
{
int n, i, v[100], odd;
for(i=1;i<=n;i++)
{cin>>v[i];
if(v[i]%2==1) odd=1;
}
if(odd==1) cout<<”yes”;
else cout<<”no”;
return 0;
}

You might also like