ex76122.cpp
来源:互联网 发布:淘宝企业店运营方案 编辑:程序博客网 时间:2024/05/21 22:50
/**************************************************************************
PURPOSE: calculate the counts of positive and negative numbers in an array
TIME: 08/10/25
AUTHOR: ch8_daniel
INPUT: arr------an array contains numbers
OUTPUT: the counts of positive and negative numbers
VERSION: 1.0
**************************************************************************/
#include <iostream>
using namespace std;
int main()
{
const int length = 12; // the length of the array;
int arr[length] = {1,2,4,5,-5,-2,4,-5,7,12,-3,-22};
int pos = 0;
int neg = 0;
for(int i = 0;i < 12;i++){
if(arr[i] < 0) neg++;
if(arr[i] > 0) pos++;
}
cout << ">>The count of positive numbers in the array is : " << pos << endl
<< ">>The count of negative numbers in the array is: " << neg;
return 0;
}
PURPOSE: calculate the counts of positive and negative numbers in an array
TIME: 08/10/25
AUTHOR: ch8_daniel
INPUT: arr------an array contains numbers
OUTPUT: the counts of positive and negative numbers
VERSION: 1.0
**************************************************************************/
#include <iostream>
using namespace std;
int main()
{
const int length = 12; // the length of the array;
int arr[length] = {1,2,4,5,-5,-2,4,-5,7,12,-3,-22};
int pos = 0;
int neg = 0;
for(int i = 0;i < 12;i++){
if(arr[i] < 0) neg++;
if(arr[i] > 0) pos++;
}
cout << ">>The count of positive numbers in the array is : " << pos << endl
<< ">>The count of negative numbers in the array is: " << neg;
return 0;
}
- ex76122.cpp
- cpp
- CPP
- CPP
- cpp
- cpp
- CPP
- CPP
- ClientSockThread.cpp&&ClientUrlThread.cpp
- cpp调用其他cpp
- ex34a.cpp&&ex34aDoc.cpp&&ex34aView.cpp
- MainFrm.cpp&&ServerThread.cpp&&SheetConfig.cpp
- CPP thread
- cpp->html
- CFaderWnd.cpp
- PasswordReminder.cpp
- object.cpp
- CmdTarget.cpp
- 校园招聘(笔试)
- 简单入门正则表达式 - 第七章 字符串、行和词边界
- c++
- Google Chrome Source Code 源码下载
- Samsung原版44B0X的Bootloader分析
- ex76122.cpp
- ex82135.cpp
- c++控制结构
- ex83135.cpp
- ex81113.cpp
- 在这里请教一个问题
- ex75122.cpp
- VS2005 SP1安装问题
- ex66104.cpp