- 博客(6)
- 收藏
- 关注
原创 枚举类型的应用
口袋中有红、黄、蓝、白、黑5种颜色的球若干。每次从口袋中任意取出3个球,问得到3中不同颜色的球的可能取法,输出每种排列的情况。分析:球的颜色只有5种,每一个球的颜色只能是这5种之一,因此可以用枚举类型变量来处理。#includeusing namespace std; int main (){ enum {red=1,yellow,blue, white ,black};
2016-10-18 11:54:53 600
原创 结构体的简单使用
#includeusing namespace std;typedef struct{ char c; int i; float f; double d;}str;int main(){ str str1, str2; str *p=&str2; str1.c='chy'; str1.d=10.0; str1. f =12; str1.i=9; p
2016-10-18 10:30:26 309
原创 3.4修改menu.cpp
#includeusing namespace std; int main(){ char c,d; cin>>c; switch (c){ case 'l':{ cout<<"You choose Left:"<<endl; cin>>d; switch(d){ case 'd':cout <<"You choose d!!!"<<en
2016-10-17 09:40:01 230
原创 3-2编程求解质数
#includeusing namespace std;int main(){int n;int c=0;while (cin>>n){ cout<<1<<endl; cout<<2<<endl; for (int j=2;j<=n;j++){ for(int i=2;i<j ;i++){ c=j%i; if(c!=0){ cout<<j<<endl;
2016-10-16 22:56:35 351
原创 Sum Problem
Problem DescriptionHey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n. InputThe input will consist
2016-10-16 19:20:29 205
原创 A+B problem
题目描述:给定两个整数A和B,其表示形式是:从个位开始,每三位数用逗号","隔开。现在请计算A+B的结果,并以正常形式输出。输入:输入包含多组数据数据,每组数据占一行,由两个整数A和B组成(-10^9 输出:请计算A+B的结果,并以正常形式输出,每组数据占一行。样例输入:-234,567,890 123,456,7891,234 2,345,678样例输出:
2016-10-15 22:26:32 372
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人