摘要: #include <stdio.h>int main(){ int a=(int)3.14; printf("%d",a); return 0; } 字符型 强制类型转换为整形 阅读全文
posted @ 2022-03-01 19:42 抢你红包 阅读(31) 评论(0) 推荐(0)
摘要: #include <stdio.h>int Max(int x,int y){ if(x>y) return x; else if(y>x) return y;}int num1=10;int num2=20;int max=0;int main(){ max=Max(num1,num2); pri 阅读全文
posted @ 2022-03-01 19:38 抢你红包 阅读(32) 评论(0) 推荐(0)
摘要: #include <stdio.h>int Add(int x,int y){ int z=0; z=x+y; return z;}int a=10;int b=20;int sum=0;int main(){ sum=Add(a,b);\\x,y printf("%d",sum); return 阅读全文
posted @ 2022-02-28 21:17 抢你红包 阅读(114) 评论(0) 推荐(0)
摘要: #include <stdio.h>int a=3;int b=5;int c=a|b;int main(){ printf("%d",c); return 0;} ·\\011 | \\101 \\111 结果为7 阅读全文
posted @ 2022-02-28 20:18 抢你红包 阅读(45) 评论(0) 推荐(0)
摘要: #include <stdio.h>int a=3;int b=5;int c=a&b;int main(){ printf("%d",c); return 0; } \\011& \\101 \\001 两个&后的结果为1 阅读全文
posted @ 2022-02-28 20:12 抢你红包 阅读(95) 评论(0) 推荐(0)
摘要: #include <stdio.h>int a=1;int b=a<<2;int main(){ printf("%d\n",b);\\32个0向左移两位为00100,结果为四 return 0;} 阅读全文
posted @ 2022-02-28 20:07 抢你红包 阅读(102) 评论(0) 推荐(0)
摘要: #include <stdio.h>int i=0;int main(){ int arr[10]={1,2,3,4,5,6,7,8,9,10}; while(i<10) { printf("%d\n",arr[i]);\\访问第i+1个元素 i++; } }\\结果为1,2,3,4,5,6,7,8 阅读全文
posted @ 2022-02-28 20:01 抢你红包 阅读(23) 评论(0) 推荐(0)
摘要: \\ 字符与字符串的长度不一样 #include <stdio.h>#include <string.h>int main(){ char arr1[]="abc"; char arr2[]={'a','b','c'};\\直到遇到'\0' printf("%d\n",strlen(arr1)); 阅读全文
posted @ 2022-02-28 19:53 抢你红包 阅读(29) 评论(0) 推荐(0)
摘要: //枚举常量enum的运用 #include <stdio.h>int main(){ enum sex{Mon=1,Tues,Wed,Thurs,Fri,Sat,Sun}day; scanf("%d\n",&day); switch(day){ case Mon:puts("Monday"); b 阅读全文
posted @ 2022-02-28 17:19 抢你红包 阅读(41) 评论(1) 推荐(0)
摘要: const的运用 #include <stdio.h> int main() { const int num=4; num=8; printf("%d\n",num); } 结果运行不了,因为const是常属性,不可发生改变;num=8运行不了 阅读全文
posted @ 2022-02-28 17:12 抢你红包 阅读(23) 评论(0) 推荐(0)