包含标签 C语言 articles

位运算

一、位的概念 ???? 我们知道,在计算机中,一字节占8位(现在的某些电脑也有占16位的),这样表示的数的范围为0-255,也即00000000-11111111。位就是里面的0和1。 ???????? char c=100; ???? 实际上c应该是01100100,正好是64H。其中高位在前,低位在后。(不足位数的在值前补0) ????????????????? |??????……

Continue reading

auto、static、register及全局变量和局部变量

auto ???? auto称为自动变量 如果函数不做其他说明的话 均为自动变量 static ???? static称为静态变量。根据变量的类型可以分为静态局部变量和静态全局变量。 ?1. 静态局部变量 它与局部变量的区别在于: 在函数退出时, 这个变量始终存在, 但不能被其它函数使用, 当再次进入该函数时, 将保存上次的结果。其它与局部……

Continue reading

循环语句之间的应用分析

几种循环语句,while、do……while、for三种循环之间有时是可以互相转化的。(另外还有一种goto循环应尽量避免使用,因为其容易造成结构体混乱。)下面看一个例子,通过三种循环结构分别实现: 1、使用do……while实现一个整数的所有位数之和。 #include<stdio.h> main() { int s=0,n; printf(“p……

Continue reading

continue的用法

例:求出1--1000内所有能被3、5、7整除的所有的数。 #include<stdio.h> main() { int n; for(n=1;n<=1000;n++) { if(n%3!=0) continue; /该句表示,如果n不能被3整除,直接跳过后面的步骤,进行下一次循环,下面两个也是一样/ if(n%5!=0) continue; if(n%7!=0) continue; printf(“%d t”,n); } printf(“n”); } break与continue的区别: break语句……

Continue reading

break的用法

问题:两数和为316,其中一个数为13的倍数,另一个为11的倍数,求这两个数。 #include <stdio.h> main() { int i; for(i=1;i<316;i++) if(!((316-i13)%11)) break; /该处的条件相当于(316-i13)%110 */ printf(“%d,%dn”,i13,316-i13); } 上面的表达式是只求得第一次满足条件的就跳出。如果要求出所有的值,可以用下面的表……

Continue reading

C语言中for循环的使用

先看一个例子,很简单的20以内能被3整除的所有的整数求和。 #include <stdio.h> main() { int i,s=0; for(i=1;i<20;i++) if(i%30) s=s+i; printf(“%dn”,s); } 注意:在使用for循环时,三个条件是以;分隔的。三个条件都可以省略,但条件2如果省略,就是不判断循环条件无限循环。可以通过在后面的语句中加入break终止循环。效果也是一……

Continue reading

do……while循环

do……while循环学习示例 #include <stdio.h> main() { char ch ; int num=0; do { ch=getchar(); num++; }while(ch!=’n’); printf(“%d n”,num-1); /因为其会将回车也当成一个符号计算,所以输出结果为num-1/ } 注意:使用do……while循环时,while后面的;不能忘记写,该语句是一个执行结束。……

Continue reading

爱因斯坦阶梯

问题:在你面前有一条长长的阶梯。如果你每步跨2阶,那么最后剩下1阶;如果你每步跨3阶,那么最后剩2阶;如果你每步跨5阶,那么最后剩4阶;如果你每步跨6阶,那么最后剩5阶;只有当你每步跨7 阶时,最后才正好走完,一阶也不剩。请问这条阶梯至少有多少阶? 分析:所求的阶梯数应比 2、3、5、……

Continue reading

C语言精句汇总

慢慢的日积月累吧!先发一下先,学到好的再往下接。 while(putchar(getchar())!=’.’); 将输入的字符串输出,当遇到.时退出。 while(c=getchar()) !=’Y’ || c!=’y’ || c!=’N’ || c!=’n’ 当c接收到的字符为y、Y、N、n时停止接收字符。……

Continue reading

switch、case的使用

代码如下: #include <stdio.h> main() { char c; printf(“please input ‘0’ to ‘9’ ;”); c=getchar(); switch(c) { case ‘0’:printf(“Sundayn”);break; case ‘1’:printf(“Mondayn”);break; case ‘2’:printf(“Tuesdayn”);break; case ‘3’:printf(……

Continue reading

Latest articles

Categories

Tags

ACL AD AES AI AWS Ansible Atlassian Azure BMC Blockchain Brocade CDH5 CL210 Cobbler Confd C语言 DDOS DISTINCT DNS Duckdb EKS ELK GCP Ghost Git Glusterfs Go Godaddy Grafana HBA HCIE Hotspot HttpWatch IBM IIS IOS InfluxDB Ingress InnoDB JavaScript Jinja2 KVM Keepalived Mplayer MySQLdb Netlify OpenResty PM PostgreSQL QoS RH318 RH442 RHCA RHCE RHEV RSA SRE SecureCRT Statuscode SublimeText2 TC Telecom Tencentcloud VBA aira2 alpine android anpic apache apm apparmor appfog apr apt-get aria2 array atop audit awk awstats axel backdoor backup bamboo bash bat benchmark bigdata bin bind bitwise book bootstrap bsd c1000 cache capistrano catlog centos centos7 chatops chattr check_mk checkinstall cisco clearall clickhouse cloud-desktop cmdb cms collectd comm compress conver corosync cpu crontab crunchbang css curl date decode dell desktop devops df dhcp diff diskpart django docker dos2unix dpkg drupal etcd excel fail2ban fastcgi fdisk fiddler find firewalld flask flvtool ftp function fuser geek gin github gitlab glances golang google gooupadd graphviz gravatra grep grub2 hadoop haproxy hardware heartbeat helm hexdump hhvm history html http/html/web httplogs https huawei huaweicloud hugo icmp iconv ifconfig inotify iopp ipmitool iptables iredmail iscsi isito it-news java jdk jenkins jira join joomla k3s k8s kdump kernel kingate lamp last leetcode lib light-http linux linux高级篇 ln ls lsi lsof lvm lvs mac mail man mark markdown matplotlib maven memcached microservice mimikatz mkdocs mkpasswd mmonit mod_jk mongodb monit monitor mono moodle mosh mount mpm mrtg mtr my.cnf mysql mysqlbinlog mysqld_multi mysqldump mysqlhotcopy nagios nc nethogs nexus nfs nginx nmon nocatlog node.js nrpe ntfs ntop ntp obs ocr open-falcon openbox opencv openldap openssl openstack oracle oswatch paas pacemaker pam pandas parted pcp pcre pdf percona perl pexpect pgrep php php-fpm ping plsql develope postfix powershell prettify proc prometheus puppeteer pushd pwgen pxe pyecharts python python模块 radmin raid rdesktop read redhat redis redmine regex rh134 rhel7 rhel8 rm rman rootkit route rpm rpmforge rrdtool rsync rsyslog safe saltstack samba scapy screen sed selenium selinux seo seq session set shc sheepdog shell shopt sitemap skydns smokeping snffier snmp socket soft sort spider sql sqlserver squid ss ssh sshpass strace strings su sudo suse svn sysbench syslog-ng sysstat systemd t tar tcpcopy tcpdump tech telnet tengine test testlink threads time tmux tomcat touch tr tsar twisted ubuntu udev ulimit unix unixbench user-agent useradd varnish vbs vercel vi vim visudo vmstat vmware vnc voice vpn vscode vsftp vsftpd vue watchdog web webcam webistrano wget wiki windows wol wordpress workshop wsl x-windows xampp xcache xmllint xtrabackup yule yum zabbix zeromq zip zonetime zookeeper 下载工具 云主机 云原生 代理 加密 古意 吐槽 圈里圈外 娱乐 字符串函数 安全 平台架构 意林 推理 提权 故事汇 故障案例 数据结构 每日看点 民国史 生活 科学记录 站长管理工具 算法 管理 网站架构 翻墙 股票 行业 诗韵 负载均衡 远程管理 面试题

Links

Meta