#include <iostream>
using namespace std;
int main()
{
int n, x = 0, count = 0;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++)
{
cin >> arr[i];
for (int i = 0; i < n; i++)
{
if (arr[i] > 0 && x == 0)
{
cout << i; //положительный
x = 1
}
if (arr[i] < 0) count++;
}
cout << endl << count;
return 0;
}
Объяснение:
Введите сначало количество елементов массива, а потом сами елементы через пробел
Выведет номер первого положительного и количество отрицательных.
#include <iostream>
using namespace std;
int main(){
unsigned short int Picture[4][4];
unsigned short int AverageBrightness = 0;
for(unsigned short int y = 0;y < 4;y++){
for(unsigned short int x = 0;x < 4;x++){
std::cin >> Picture[y][x];
AverageBrightness = AverageBrightness + Picture[y][x];
}
}
AverageBrightness = AverageBrightness / 16;
for(unsigned short int y = 0;y < 4;y++){
for(unsigned short int x = 0;x < 4;x++){
if(Picture[y][x] < AverageBrightness){
Picture[y][x] = 0;
}else{
Picture[y][x] = 255;
}
}
}
for(unsigned short int y = 0;y < 4;y++){
for(unsigned short int x = 0;x < 4;x++){
std::cout << Picture[y][x];
}
}
return 0;
}
Объяснение: