随笔分类 - C语言
摘要:一开始打算用Java写,结果写完加法就卡住了。打算再思考下,就想起了之前用c写计算器的例子,翻开书本照着又打了一遍,希望能让我有点思路,不过缺点是这段代码只能运行两位数的计算,等我过段时间看看能不能给它升级一下^ _ ^ #include<stdio.h> int main() { int date
阅读全文
摘要:字符串的表示 char str1[100] = {'A', 'd', 'a','\0'}; char str2[100] = "Ada"; char str3[100]; str3 = "Ada" // 错误!表示一个储存多个字符的数组,且不能用=赋值 strcpy(str3, "Ada"); //
阅读全文
摘要:第1关:汽车销量排序 本关任务:需要对2019年主要汽车集团全球的汽车销量进行统计,编写一个程序,按从大到小的顺序对销量进行排序 #include <stdio.h> void carSort(long car[]); //排序函数 int main() { int i; long car[10
阅读全文
摘要:第1关:查找整数 题目描述:给出一个包含n个整数的数列,问整数a在数列中的第一次出现的位置是多少(从1开始) #include<stdio.h> int main(void) { /*********Begin*********/ int a[1000]; int i, n, b, p; sca
阅读全文
摘要:记录一下 ```C #include<stdio.h> int main() { int a[100], key, index = -1, high, low, mid, i, m; scanf("%d", &m); for (i = 0; i < m; i++) { scanf("%d", &a[
阅读全文
摘要:第1关:求和 题目描述:给你一个n,要求你编写一个函数求1+2+.......+n #include<stdio.h> int fact(int x) { int m, sum = 0; for (m = 1; m <= x; m++) sum += m; return sum; } int m
阅读全文
摘要:第1关:乘法表 本关任务:输出n * n乘法表 #include <stdio.h> int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { printf
阅读全文
摘要:第1关:计数控制循环--偶数之和 从键盘输入6个整数,计算其中大于0的偶数之和 #include <stdio.h> #include <math.h> int main() { int a, sum = 0; for (int i = 0; i < 6; i++) { scanf("%d",
阅读全文
摘要:第1关:求字母 本关任务:输入一个小写字母求其后面的第二个字母.如字母d后面的第二个字母为f, 字母y后面的第二个字母为a #include <stdio.h> int main() { char ch; scanf("%c",&ch); if(ch<=120) //判断字母位置 ch=ch+2
阅读全文
摘要:恢复内容开始 # 第1关:求立方 本关任务:输入一个整数n(-1000<=n<=1000),求n的立方 ``` #include int main() { int a; scanf("%d", &a); printf("结果=%d", a * a * a); return 0; } /* 方法二 #
阅读全文
摘要:第1关:打印输出 Hello World 编程要求:使用printf()在屏幕上输出 Hello World #include<stdio.h> int main(){ printf("Hello,World"); return 0; } 第2关:打印输出图形 编程要求:编写一个能输出规定图形的程序
阅读全文