- 博客(21)
- 收藏
- 关注
原创 12号了
元旦忙到现在,很久没来了.最近很累.接触了好多东西,去年年底搞定了C#开发的平台,今年接触了CMS系统,马上还要做购物网站.总的感觉就是累,但是也很充实.希望今年丰收!
2010-01-12 11:35:00
301
原创 第五章 7,8
7.读入单词,直到用户输入done为止.并计算输入的单词个数.#include int main(){ using namespace std; char ch[20]; int count=0; cout cin>>ch; while(strcmp("done",ch)) { cout ++count; cin>>ch; } cout return 0;}===========
2009-10-20 22:51:00
340
原创 第五章6
#include using namespace std;struct car{ char product[20]; int year;};int main(){ cout int n; cin>>n; car *obj=new car[n]; int i=0; for(i=0;i { cout cout cin>>obj[i].product; cout cin>>(
2009-10-20 21:58:00
285
原创 第五章第5题
#include void main(){ using namespace std; int sales[3][12]; int sale; int sum1; int sum2[3]; int sum=0; int i=0; int j=0; for (i=1;i { sum1=0; for(j=1;j { cout cin>>sales[i][j]; cout su
2009-10-20 17:55:00
320
原创 第五章习题
1.编写一个要求用户输入两个整数的程序.该程序将计算并输出这两个整数之间所有整数的和.这里假设选输入较小的整数.例如,如果用户输入的是2和9,则程序将指出2~9之间的所有整数的和为44.#includeint main(){ using namespace std; cout int i,j; cin>>i; cout cin>>j; int sum=0; for(int k=i;k
2009-10-19 18:31:00
725
原创 int x=(1,024)与int y;y=1,024
#includeint main(){ using namespace std; int i=(1,024); cout int j; j=1,024; cout return 0;} 运行:201 因为i=(1,024)用逗号操作符连接,值为右侧表达式的值.这是024,八进制为20因此这里声明将值20赋给i. j=1,024实际为(
2009-10-19 18:28:00
1555
原创 创建结构candybar,要求用new来动态分配结构数组
#include struct CandyBar{ char kind[20]; float weight; int cal;};int main(){ using namespace std; int size; cout cin>>size;//数组的元素数 cin.get(); CandyBar *ps=new CandyBar[size];//创建一个动态数组 //从
2009-10-15 18:22:00
864
原创 读取字符串,数字并输出
#include int main(){ using namespace std; cout char firstname[20]; cin.get(firstname,20); cin.get(); cout char lastname[20]; cin.get(lastname,20); cin.get(); cout char letter; cin>>letter; letter
2009-10-15 14:22:00
480
原创 数组指针习题
11、输入一个正整数,然后创建一个动态的int数组,其中包含的元素个数等于用户输入的值cin>>size;int p[]=new int[size]; 12、下面的代码是否有效?如果有效,它将打印出什么结果?cout 运行结果:0040564C 13、编写一段代码,给问题6中描述的结构动态分配内存,然后读取该结构的成员的值。问题6:设计一个描述鱼的结构声
2009-10-14 21:59:00
457
原创 整数小数相互转换
#include int main(){ using namespace std; int du; int fen; int miao; cout cout cin>>du; cout cin>>fen; cout cin>>miao; double x; x=du+fen/60.0+miao/3600.0; cout return 0;}
2009-10-12 10:14:00
650
原创 分别输入小时和分钟,得到形如 9:28
#include using namespace std;void time(int h,int m){ cout}int main(){ cout int i,j; cin>>i; cout cin>>j; time(i,j); return 0;}
2009-10-10 16:30:00
405
原创 一光年等于63,420天文单位
#include "stdafx.h"#include using namespace std;double convert(double c){ double fah = 63240*c; return fah;}int main(){ cout double c; cin>>c; cout return 0;}
2009-10-10 16:25:00
579
原创 判断一个句子的单词中是否有句号,若有,则显示第几个单词中第几个位置上;若无,则返回flase
class justiceflag{ public static void main(String[] args){ int i=0;//句中第i+1个单词 int j=0;//单词里的第j+1个字母 int k=0; int h=0; char[] ch1=new char[100];//存放单词里字母的数组 char[] ch2=new char[100]; String tex
2009-09-29 06:23:00
687
原创 只能实现一个单词,且最后带“.”,逆序如:ASbsa.运行得到:.asbSA
class daoxu{ public static void main(String[] args){ int i=0;//句中第i+1个单词 int j=0;//单词里的第j+1个字母 int k=0; int h=0; char[] ch1=new char[10];//存放单词里字母的数组 char[] ch2=new char[10]; String text="ASBsa
2009-09-28 22:22:00
319
原创 To beyond 转换为:oT dnoyeb
//和要求不完全一样,还不能实现带标点的如To be. 会变成oT .eb,而不是oT eb.class daoxu{ public static void main(String[] args){ int i=0;//句中第i+1个单词 int j=0;//单词里的第j+1个字母 int k=0; char[] ch1=new char[10];//存放单词里字母的数组 char[
2009-09-28 17:11:00
463
原创 分解12/29/2009 输出:29th Dec 2009
class date{ public static void main(String[] args){ int i=0; int j=0; String daya = "";//存储天 String month ="";//存储月 String year ="";//存储年 String[] dates = {"07/01/07","09/09/09","07/27/99","12/3
2009-09-28 15:42:00
271
原创 将一段话切分成单词,按字典顺序排序
class mp{ public static void main(String[] args){ int i=0; int j=0; String temp=""; String article=" The Source for Java Developers"; String[] words=article.split("[ ]"); j=words.length;//切分成j个
2009-09-28 14:30:00
1457
原创 乘法表 右对齐打印
class mul{ public static void main(String[] args){ int i=0; int j=0; String s1=""; String s2=""; int[][] nums = new int[13][13]; if (i==0&&j==0) { System.out.print(" ");//第一行第一列显示空白
2009-09-28 13:29:00
1180
原创 随机生成12个数,并显示对应的月份
创建一个String数组并用1月~12月的月份名称初始化数组,再创建一个包含12个0~100之间的随机十进制的数组.然后将每个月份的名字连同相应的十进制显示出来,最后计算并显示这12个十进制的平均值. 我是这么做的,months[i]代表i月;随机生成12个数,如果有在0~11之间的,就打印出数和对应的月份 class month{ public static void main(
2009-09-28 12:01:00
1860
原创 编写一段程序生成一组随机序列的大写字母,其中不要包含元音字母
class num{ public static void main(String[] args){ char ch; //System.out.print((char)(65)); //大写字母A对应65 //System.out.print((char)(90)); //大写字母Z对应90 for(int j=0;j int i=(int)(128*Math.random());
2009-09-28 10:24:00
1595
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人