C++第五次实验
来源:互联网 发布:企业如何进行网络推广 编辑:程序博客网 时间:2024/06/05 09:37
#include <iostream> using namespace std; int main( ) {int a[10],x(0),y(0),i;for(i=0;i<10;i++){cin>>a[i];if(a[i]>0) x+=a[i];else if(a[i]<0) y+=a[i];}cout<<"正数和为"<<x<<"负数和为"<<y<<endl;return 0;}
#include <iostream>using namespace std; int main( ) {int a[10],b[10],c[10],i,j(0),k(0);for(i=0;i<10;i++){cin>>a[i];if(a[i]%2==1) b[j]=a[i],j++;else if(a[i]%2==0) c[k]=a[i],k++;}for(i=0;i<j;i++)cout<<b[i];cout<<endl;for(i=0;i<k;i++)cout<<c[i];return 0;}
#include<iostream> #include<cstdio> using namespace std; int main() { char str[50]; int i=0,x=0,y=0,z=0; cout<<"输入字符串:"; gets(str); while(str[i]!='\0') z++; while(str[i]!='\0') { if(str[i]>='0'&&str[i]<='9') x++; i++; } while(str[i]!='\0') { if(str[i]>='A'&&str[i]<='Z') y++; i++; } while(str[i]!='\0') { if(str[i]>='a'&&str[i]<='z') y++; i++; } cout<<"其中的数字个数是: "<<x<<endl; cout<<"其中的字母个数是: "<<y<<endl; cout<<"其中的其它字符个数是: "<<z<<endl; return 0; }
0 0
- 第五次C语言上机实验报告
- 第五次C程序设计实验报告
- 第五次C语言上机实验报告
- C语言第五次上机实验
- 第五次实验
- 第五次上机实验
- 第五次上机实验
- 第五次上机实验
- 第五次上机实验
- 第五次上机实验
- 第五次上机实验
- 第五次实验报告
- 第五次上机实验
- 第五次上机实验
- 第五次上机实验
- 第五次上机实验
- 第五次上机实验
- 第五次上机实验
- 人工智能全景图
- switch详解
- Problem E: 分数类的乘法
- hdu 1598 find the most comfortable road
- 最新第三方库
- C++第五次实验
- 电脑技巧汇总
- CSS伪类+border实现Banner标签、冒泡式提醒等
- Problem F: 分数类的模板数组类
- linux上zookeeper集群的安装、配置和高可用测试
- Oracle日常性能查看
- 锚点回顶部js
- ElasticsearchCRUD使用(十一)【Elasticsearch同义词分析器】
- Hierarchy Viewer使用详解