编写一个程序,把一个数组中的负数打印出来,并输出这些负数的和。数组为:-5,65,-32,98,-54,0,-307

[复制链接]
查看11 | 回复5 | 2011-3-23 18:58:53 | 显示全部楼层 |阅读模式
要用到switch语句哦!高手帮忙啊

回复

使用道具 举报

千问 | 2011-3-23 18:58:53 | 显示全部楼层
////////////////////////////////////////
作者:jierandefeng////
时间:2011.3.2318:57////////////////////////////////////#include void main(){ int arr[]={-5,65,-32,98,-54,0,-307};
for(int i=0;i<=7;i++) //循环 {long int x=(a
回复

使用道具 举报

千问 | 2011-3-23 18:58:53 | 显示全部楼层
int main(int argc, char* argv[]){ int s[] = {5, 65, -32, 98, -54, 0, -307}; int t, sum = 0, i; for (i = 0; i < 7; i++) {t = (s < 0);switch (t){case 1:
回复

使用道具 举报

千问 | 2011-3-23 18:58:53 | 显示全部楼层
#include void main(void){ double a[10]={-5,65,-32,98,-54,23,0,76,-307,-2}; double s(0); for(int i=0;i<10;i++) {if(a<0) { cout<<a<<endl;
回复

使用道具 举报

千问 | 2011-3-23 18:58:53 | 显示全部楼层
#includeusing namespace std;int main(){int a[-5,65,-32,98,-54,0,-307],i;for(i=0;i<6;i++){if(a<0)cot<<a<<" ";}cout<<endl;return 0;}
回复

使用道具 举报

千问 | 2011-3-23 18:58:53 | 显示全部楼层
既然有了,那我就不回答了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行