- 博客(43)
- 收藏
- 关注
原创 class 4
// omputer.h: interface for the Computer class.////////////////////////////////////////////////////////////////////////#if !defined(AFX_OMPUTER_H__2C841290_BF9E_410C_960A_9E152D78E5D0__INCLUDED_)
2016-03-23 15:43:45
341
原创 third class 函数
//default.cpp//default parameter:缺省(默认)参数#inclideusing namespace std;int max(int a[],int n=2)//n=2 默认数组元素个数{ int t=a[0]; for(int i=1;i<n;i++) t=(a[i]>t)?a[i]:t; return t;}//dynamically all
2016-03-09 15:44:25
448
原创 second class
#includeusing std::cout;//identifier(名字,标示符) scope(作用域)using std::cin;// using directive(using指令)using std::endl;// pass by value - 传值调用int add(int x, int y)//形参{return x+y;}//pass by addres
2016-03-02 15:32:13
298
原创 C++ first class
#includeusing std::cout;using std::cin;using std::endl;//using namespace std;//名字空间(namespace) name clashingint main(){ int x = 10; float f = 0.23; char s[]="Ligang"; std::cout<<"Hello,"
2016-03-02 14:42:06
370
原创 图还未完成
#include#include#include#include#define OK 1#define ERROR 0#define OVERFLOW -2#define MaxInt 32767#define MVNum 100bool visited[MVNum];typedef int status;typedef char VerTexType;//假设定点的类
2015-12-09 15:52:36
429
原创 错误栈
#include#include#include#include#include#define MAXSIZE 100#define OK 1#define ERROR 0#define OVERFLOW -2#define INFEASIBLE -1typedef int SElemType;typedef int Status;typed
2015-11-25 16:39:12
404
原创 P124 第三章 42题 超过平均数的个数
/* Note:Your choice is C IDE */#include "stdio.h"int Count(double a[], int n){ int i, b = 0; double ave,sum = 0; for(i = 0; i < n; i++) sum += a[i]; ave = sum/n; for(i = 0; i < n; i
2015-05-31 20:16:58
320
原创 P124 第三章 41题 验证哥德巴猜想
/* Note:Your choice is C IDE */#include "stdio.h"int prim(int num){ int a = 0,i; for(i = 2; i < num; i++) { if(num% i== 0) a = a + 1; } return a;
2015-05-31 20:04:46
742
原创 P124 第三章 40题 求多项式的值
/* Note:Your choice is C IDE */#include "stdio.h"float fun(int n){ float Sn = 1; float i, s = 1; for(i = 1; i <= n; i++) { s *= i; Sn += 1/s; } return Sn;}void main(){ in
2015-05-31 18:53:52
446
原创 P124 第三章 39题 求某数的几次方的值
/* Note:Your choice is C IDE */#include "stdio.h"int fun(int a, int n){ int i, sum = 1; for(i = 1; i <= n; i++) sum *= a; return sum;}void main(){ int x,y; while(1) { scanf("
2015-05-31 18:22:38
362
原创 P123 第三章 38题 求几个数的多次方之和
/* Note:Your choice is C IDE */#include "stdio.h"int powers(int m, int n){ int i, sum = 1; for(i = 1; i <= n; i++) sum *=m; return sum;}int sum_of_powers(int k, int n){ int j, sum = 0
2015-05-31 18:05:42
326
原创 P123 第三章 30题 杨辉三角
/* Note:Your choice is C IDE */#include "stdio.h"void line(int a,int b){ int m = a,n = b; int s = 1,t = 1; int consult,c; b = b-1; a = a-1; c = b; for(b; b > 0; b--) s = s*b; for(c; c > 0
2015-05-31 13:57:46
519
原创 P122 第三章 10题 三角形的面积及三边是否能组成三角形的判断
#include#includevoid Judge(float a, float b, float c){ float S,p; if(a+b>c&&a+c>b&&b+c>a) { p = (a+b+c)/2; S = sqrt(p*(p-a)*(p-b)*(p-c)); printf(
2015-05-15 23:38:11
374
原创 P123 第三章 29题 产生随机数
#include #include void main() { int i,j,k,temp; srand(5); int a[10000]; for(i = 0; i < 10000; i++) a[i] = rand(); for(j = 0; j < 10000; j ++) { if(a[j]<a[j-1]) { te
2015-05-15 11:47:30
327
原创 P123 第三章 题36 月份转换成英文
#include #include void printdate(int year,int month,int day){if(year12||day31)printf("here your wrong\n");switch(month){ case 1: printf("January %d,%d\n",year,day);
2015-05-15 11:32:09
511
原创 P123 第三章 28题 字符串的大小写转换
/* Note:Your choice is C IDE */#include #includevoid main(){ char ch[100]; int i; printf("请输入字符串:\n"); scanf("%s",&ch); for(i=0;ch[i]!='\0';i++) { if(ch[i]>='a'&&ch[
2015-05-07 21:55:42
338
原创 P122 第三章 20题 十进制转换其他进制
/* Note:Your choice is C IDE */#include "stdio.h" Trans(int x,int base){ int i=0,a[100]={0}; if(base = 2){ for(x;x>0;i++) { a[i] = x%2; x=x/2; } for(i;i > 0;i--) { printf("%d",a[i-1])
2015-05-07 21:14:13
402
原创 P122 第三章 16题 n个数中大于等于平均值的个数
/* Note:Your choice is C IDE */#include "stdio.h"Number(int a[],int x){ int i,j,k = 0,s = 0; for(i = 0; i < x; i++) s = s + a[i];printf("Average of those numbers:%d\n",(s/x));for(j = 0; j
2015-05-07 20:20:11
409
原创 P122 第三章 21题 十个学生的最高分 平均值,及格人数
#includeint main(){ float a=0,b,h[10],max; int i,j=0; printf("请输入十个学生成绩\n"); for(i=0;i<10;i++) scanf("%f",&h[i]); max=h[0]; for(i=0;i<10;i++) { if(max<h[i]) max=h[i]; } for(i=0;i<10;
2015-04-24 17:19:48
415
原创 P122 第三章 17题 求十个数的数组的平均值
#includeint main(){ int a[10]; int i; float s=0,v; for(i=0;i<=9;i++) scanf("%d",&a[i]); for(i=0;i<=9;i++) { s+=a[i]; } v=s/10; printf("%f",v); return 0;}
2015-04-24 17:13:51
431
原创 P122 第三章 15题 插入一个数按原来排序方式
#includeint main(){ int a[11]={1,3,6,7,8,12,16,22,33,36}; int i,j,temp; int x=a[10]; scanf("%d",&a[10]); for(j=0;j<=10;j++) { for(i=0;i<10-j;i++) { if(a[i]>a[i+1]) { tenp = a[
2015-04-24 16:59:45
283
原创 P122 第三章 14题 参数逆转
#include void Reserse(unsigned int s){for(int i=1;i<= sizeof(s)+5;i++){ int k = s%10; int j = k; s=(s-j)/10;printf("%d",k);}}void main(){ int n; printf("输入一个参数:"); scanf("%d",&n);
2015-04-24 13:12:40
255
原创 p122 第6题 小写转大写
/* Note:Your choice is C IDE */#include #include "stdio.h"void up(char ch){ if(ch >= 'a' && ch <= 'z') putchar(toupper(ch)); else printf("%c",ch);}
2015-04-23 20:00:42
471
原创 week7_黑板抽查题目,按从小到大排序
#include void Print(int a[],int x){ for(int i = 0; i < x; i++){ printf("%d ",a[i]); } printf("\n ");}void Sort(int a[],int x){ int i,j,k; for(i = 0; i < x; i++) {
2015-04-17 11:18:19
268
原创 输入一些数,按从小到大排序
/* Note:Your choice is C IDE */#include "stdio.h"void main(){ int a[10],i,j,k; for(i = 0; i < 10; i++) { scanf("%d",&a[i]); for(j = i; j > 0; j--) { if(a[j] < a[j-1])
2015-04-17 07:37:59
483
原创 51页19题 判断一个正整数是否奇偶交替
/* Note:Your choice is C IDE */#include "stdio.h"void main(){ int n,flag; printf("请输入一个正整数:\n"); scanf("%d",&n); do{ flag = n%2; n = n/10; }while( n&&((!flag) == n%2) );
2015-04-16 21:14:00
518
原创 51页20题 多少年后工业总产值超过500
/* Note:Your choice is C IDE */#include "stdio.h"void main(){ int y,n; float x,m; printf("请输入年份:\n",y); scanf("%d",&y); printf("请输入工业总产值:\n",x); scanf("%f",&x); m = x;
2015-04-16 18:46:10
300
原创 51页 17题输出2-n之间的所有素数
#include #includeint main(){ int n; int i,j; printf("请输入n的数值:\n"); scanf("%d",&n); for(j = 2;j { for(i = 2; i j%i != 0; } printf("%d为质数\n",j ); return 0;}
2015-04-10 12:00:11
1031
原创 51页15题,倒三角形
/* Note:Your choice is C IDE */ #include "stdio.h" void main() { int i,m,n,x; printf("请输入一个正整数:\n"); scanf("%d",&x); for(i = x; 1 <= i ; i--) { for(n =
2015-04-09 23:08:04
404
原创 51页15题n行的正三角形
/* Note:Your choice is C IDE */#include "stdio.h"void main(){ int i,m,n,x; printf("请输入一个正整数:\n"); scanf("%d",&x); for(i = 1; i <= x; i++) { for(m = 1; m <= (x-i); m++)
2015-04-08 23:02:29
530
原创 51页14题,斐波那契分数序列前n项和。
/* Note:Your choice is C IDE */#include "stdio.h"void main(){ int x,i; float m,n,M,N; float y,z; n = 2; m = 1; y = 2; printf("输入需要运算的项数:"); scanf("%d",&x); for(i
2015-04-08 21:26:12
541
原创 51页13题 输入一串字符,统计字母个数和数字个数,直到输入*为止
#include main( ) { int a,b,c; char ch; a=0;b=0; while(ch!='*') {
2015-04-03 09:58:55
2335
原创 51页 12 题:爱因斯坦数学题
/* Note:Your choice is C IDE */#include "stdio.h"void main(){ int x; for(x = 0;x< 1000;x++) if((x%2==1)&&(x%3==2)&&(x%5==4)&&(x%6==5)&&(x%7==0)) printf("%d\n",x); }
2015-04-03 09:58:21
743
原创 51页 10题 输入年号和月份,输出这一年该月的天数
/* Note:Your choice is C IDE */#include "stdio.h"void main(){ int x=0,y=0; printf("请输入年号和月份:"); scanf("%d %d",&x,&y); if((y==1)||(y==12)||(y==8)||(y==10)||(y==3)||(y==5)||(y==
2015-04-02 18:45:53
1686
原创 51页 9题 判断一个点在圆上圆内还是圆外。
#include #includeint main(){ int a,b,c; c=(a-2)*(a-2)+(b-2)*(b-2); printf("输入x,y的值:\n"); scanf("%d %d",&a,&b); if(c>1) printf("该点在○外\n"); if(c==1) printf("该点在圆内\n");
2015-03-27 11:49:51
2182
原创 51页 8题 输入整数a和b,如果a能b整出,输出算式和商,否则输出算式、整数商和余数
#include #includeint main(){ int a,b,c;printf("输入a,b的值:");scanf("%d %d",&a,&b);if(b%a == 0) { printf("%d/%d=%d\n 余数为0\n",b,a,b/a);}else { c=b/a;printf("%d/%d=%d\n
2015-03-27 11:20:33
2649
原创 51页第七题
#include #includeint main(){ char a,b,c;printf("输入两个数值:\n");scanf("%c %c",&a,&b);c = a-b;if(c%2==0) if(a>b){ a++;printf("%c\n",a);}else if(c%2 != 0)printf("%c\n",(b
2015-03-27 10:50:36
463
1
原创 输出1000-1999之间的闰年
#include int main(){ int a,b; for(a=1000;a<2000;a++) { if ((a%4==0&&a%100!=0)||(a%400==0)) { printf("%d\t",a); b++; if (b%3==0) printf("\n"); } } ret
2015-03-27 10:19:53
676
原创 判断用户输入的是数字还是字符
#include #include int main(){ char ch ; printf("请输入数值或字母:\n"); ch=getchar(); if(ch>='0'&&ch<='9') printf("this is a numerical character"); if(ch>='a'&&ch='A'&&
2015-03-26 22:49:10
698
原创 1.输入x2的值 2. 10个数中输出最小
#include #include int main() { int i,j,c;for( i = 0; i <10; ++i) { { c=i*i; printf("%d*%d=%d\t",i,i,c); } printf("\n"); } return 0; }
2015-03-26 22:41:58
311
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人