![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c
文章平均质量分 63
garnett2003
这个作者很懒,什么都没留下…
展开
-
补码知识
<br />1、补码概述:<br />在计算机系统中,数值一律用补码来表示(存储)。<br />主要原因:使用补码,可以将符号位和其它位统一处理;同时,减法也可按加法来处理。另外,两个用补码表示的数相加时,如果最高位(符号位)有进位,则进位被舍弃。<br />2.、补码与原码的转换<br />补码与原码的转换过程几乎是相同的。<br />数值的补码表示也分两种情况:<br /> (1)正数的补码:与原码相同。<br /> 例如,+9的补码是00001001。<br />原创 2010-07-27 13:52:00 · 1183 阅读 · 1 评论 -
c程序基本算法百例之四—歌手大奖赛评分
#include#includeintmain(){ int integer,i,max,min,sum; max = -32768; //先假设当前最大值为c语言整型数的最小值 min = 32767; //先假设当前最小值为c语言整型数的最大值 sum = 0; //要去累加和值得初原创 2011-05-10 10:15:00 · 1166 阅读 · 0 评论 -
c程序基本算法百例之二—绘制余弦曲线和直线
#include #include main(){ double y; int x,m,n,yy; for(yy=0;yy原创 2011-04-29 00:44:00 · 538 阅读 · 0 评论 -
c语言基本算法程序百例之十—数值转换
#includevoid printb(int,int);int main(){ int x;printf("Input number:"); scanf("%d",&x); printf("number of decimal form:%d/n",x); printf(" its binary form:"); printb(x,s原创 2011-06-21 09:25:00 · 607 阅读 · 0 评论 -
c程序基本算法百例之一—绘制余弦曲线
#include #include main(){ double y; int x,m; for (y=1;y>=-1;y-=0.1) //y为列方向,值从1到-1,步长为0.1 { m = acos(y)*10; //计算出y对应的弧度m,乘10为图形放大倍数 for (x=1;x原创 2011-04-26 11:03:00 · 683 阅读 · 0 评论 -
c语言基本算法程序百例之九—杨辉三角形
#includeintmain(){ int i,j,n=13; printf("N="); while(n>12) //控制输入正确的值以保证屏幕显示的图形正确 scanf("%d",&n); for(i=0;i<=n;i++)原创 2011-06-10 17:54:00 · 1388 阅读 · 0 评论 -
c程序基本算法百例之八—借书方案知多少
<br />#include"stdio.h"intmain(){ int a,b,c,count=0; printf("借书方案为:/n"); for(a=1;a<=5;a++) for(b=1;b<=5;b++) for(c=1;a!=b&&c<=5;c++) if(c!=a&&c!=b) printf(count%5?"%2d:%d,%d,%原创 2011-05-15 16:06:00 · 1293 阅读 · 0 评论 -
c程序基本算法百例之七—阶层尾数零的个数
<br />#include<stdio.h>#include<math.h>intmain(){ int a,count = 0; for(a=5;a<=100;a+=5) //循环从5开始,以5的倍数为步长,考察整数 { count++; //若为5的倍数,计数器加1 if(!a%25)count++; //若为25的倍原创 2011-05-11 16:29:00 · 1025 阅读 · 0 评论 -
c程序基本算法百例之三—绘制圆
#include#includemain( ){ double y; int x,m; for(y=10;y>=-10;y--) //圆的半径为10 { m=2.5*sqrt(100-y*y);//计算y对应的列坐标m,2.5是屏幕纵横比调节系数,因为屏幕的行距大于列距,不进行调节显示出来的是椭圆 for(x=1;x原创 2011-05-09 18:58:00 · 582 阅读 · 0 评论 -
c程序基本算法百例之五—求最大公约数
<br />#include <stdio.h>#include <math.h>intmain(){ long i; //使用长整型,范围较大 int j; printf("Please input number:"); scanf("%ld",&i); for(j=999;j>=100;j--) //所有约数从大到小,第一个约数既是最大的三位公约数 if原创 2011-05-10 14:37:00 · 602 阅读 · 0 评论 -
Hanoi塔-函数递归方法的运用
/*Hanoi(汉诺)塔的问题。函数递归方法的经典运用。*/#include void main(){ void hanoi(int n,char one,char two ,char three); //对函数hanoi的声明 int m; printf("input the number of diskes:"); scanf("%d",&m); printf("The step to moveing %d diskes:/n",m); hanoi(原创 2011-02-21 11:19:00 · 1914 阅读 · 0 评论 -
经典的冒泡排序法
/*经典的冒泡排序法*/#include void main(){ int a[10]; int i,j,t; printf("input 10 numbers :/n"); for(i=0;ia[i+1]) { t=a[i]; a[i]=a[i+1]; a[i+1]=t; } printf("the sorted numbers :/n"); for(i=0;i原创 2011-02-18 00:28:00 · 641 阅读 · 0 评论 -
筛选法求100以内的素数
/*筛选法求100以内的素数算法:(1)挖去1;(2)用下一个未被挖去的数P去除P后面各数,把P的倍数挖掉;(3)检查P是否小于n的开方的整数部分,如果是,则返回2继续执行,否则就结束。(4)剩下的数就是素数。*/#include #include //程序中用到求平方根函数sqrtvoid main(){ int i,j,n,a[101]; //定义a数组中包含101个元素 for(i=1;i原创 2011-02-19 14:07:00 · 10636 阅读 · 2 评论 -
比较三个数大小
<br />/*输入a,b,c三个值,输出最大者要点:1、printf的用法 2、scanf的用法 3、可以转为函数使用*/#include <stdio.h>main(void){ int a,b,c,max; printf("please input a,b,c:/n"); scanf("%d,%d,%d",&a,&b,&c); max=a; if(max<b) max = b; if(max<c) max = c;原创 2011-02-15 11:06:00 · 548 阅读 · 0 评论 -
Pointer On C-第二章编程练习第一题函数调用
/*c和指针 第二章编程练习第一题要点:1、函数调用前要先声明 2、函数声明末尾加;号*/---------------------------------------------------#include int increment(int value); //函数调用要先声明,末尾加“;”号int negate(int value);main(void){ printf("%d %d/n",increment(10),negate(10)); p原创 2011-02-15 10:28:00 · 650 阅读 · 0 评论 -
Pointer On C-1.1
1.1.1 空白和注释(comment)空行降程序的不同部分分隔开来,制表符(tab)用于缩进语句,更好的显示程序的结构等等。注释以符号/*开始,以符号*/结束。注释不能嵌套,第一个/*符号和第一个*/符号之间的内容都被看作注释,不管里面有多少/*。注释掉一段代码,可以用/*和*/符号,但是如果这段代码内部原先就有注释存在,这样就会出问题。要从逻辑上删除一段代码,使用#if指令最为妥当。#if 0 Statements#endif1.1.2 预处理指令(preprocessor direct原创 2011-02-10 17:17:00 · 461 阅读 · 0 评论 -
c程序基本算法百例之六—高次方数的尾数
<br />#include<stdio.h>#include<math.h>intmain(){ int i,x,y,last=1; //变量last保存求X的Y次方过程中的部分积的后三位 printf("Input X and Y(X**Y):"); scanf("%d**%d",&x,&y); for(i=1;i<=y;i++) //X自乘Y次 last=last*x%10原创 2011-05-10 15:48:00 · 1506 阅读 · 0 评论