随笔分类 - c语言
摘要:1 #include<stdio.h> 2 3 int main(void) 4 { 5 int i; 6 char str[80]; 7 char ch, temp; 8 9 ch = getchar(); //需要查找的字符 10 temp = getchar(); //第一行回车 11 12
阅读全文
摘要:1 #include<stdio.h> 2 3 int day_of_year(int year, int month, int day); 4 int main(void) 5 { 6 int year, month, day; 7 8 scanf_s("%d/%d/%d", &year, &mo
阅读全文
摘要:用了两个矩阵来完成,可能会有更好的方法。 1 #include<stdio.h> 2 3 int main(void) 4 { 5 int a[6][6], b[6][6]; 6 int m, n; 7 int temp; 8 9 scanf_s("%d %d", &m, &n); 10 11 fo
阅读全文
摘要:1 #include<stdio.h> 2 3 int main(void) 4 { 5 int a[10][10]; 6 int n; 7 8 scanf_s("%d", &n); 9 10 for (int i = 0; i < n; i++) 11 { 12 for (int j = 0; j
阅读全文
摘要:1 void StringCount(char s[]) 2 { 3 int letter, blank, digit, other; 4 5 letter = 0; 6 blank = 0; 7 digit = 0; 8 other = 0; 9 10 int i = 0; 11 while (s
阅读全文
摘要:写了两个函数。 1 int even( int n ) 2 { 3 int ret = 1; 4 5 if (n < 0) 6 { 7 n = -n; 8 } 9 if (n % 2 == 1) 10 { 11 ret = 0; 12 } 13 14 return ret; 15 } 16 int
阅读全文
摘要:程序只验证了样例 1 #include<stdio.h> 2 3 int q, r; //全局变量 4 int div(int a, int b); 5 int main(void) 6 { 7 int a, b; 8 int count = 0; 9 10 scanf("%d/%d", &a, &
阅读全文
摘要:1 #include<stdio.h> 2 4 int array_in(int x, int a[], int n); 5 6 int main(void) 7 { 8 int m, n, k; //三个数组的大小 9 10 /*第一个数组,数组长度是变量,C99支持,但vs不支持*/ 11 sc
阅读全文
摘要:查找最小数下标 1 #include<stdio.h> 2 3 int main() 4 { 5 int a[10]; //定义一个数组 6 int n; //参加排序整数的个数,小于等于10 7 int temp; 8 9 scanf_s("%d", &n); 10 11 for (int i =
阅读全文
摘要:1 #include<stdio.h> 2 3 int main(void) 4 { 5 char ch; 6 int number; 7 int flag = 0; 8 int ret; 9 10 scanf("%d", &number); //读入一个数字 11 ret = number; //
阅读全文
摘要:1 #include<stdio.h> 2 3 int pow(int m, int n); 4 int main(void) 5 { 6 int n; 7 int temp; //n的绝对值 8 int count; //数的位数 9 int x; //临时变量 10 11 count = 0;
阅读全文
摘要:1 #include<stdio.h> 2 3 int main(void) 4 { 5 int n, m; 6 int i; 7 int isPrime; 8 int sum; 9 int count; 10 11 i = 2; //第一个素数 12 sum = 0; 13 count = 0;
阅读全文
摘要:1 #include<stdio.h> 2 #include<math.h> 3 4 int main(void) 5 { 6 int n; 7 int temp; //个位数 8 int flag; //奇偶标志位,1是奇数,0是偶数 9 int count; //统计数的位数 10 int re
阅读全文
摘要:/* 计算序列部分和 1 - 1/4 + 1/7 - 1/10 + ... 直到最后一项的绝对值不大于给定精度eps。 输入格式: 输入在一行中给出一个正实数eps。 输出格式: 在一行中按照“sum = S”的格式输出部分和的值S,精确到小数点后六位。题目保证计算结果不超过双精度范围。 */ #i
阅读全文
摘要:1 #include<stdio.h> 2 3 int main(void) 4 { 5 int year; 6 int month; 7 int day; 8 int a[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; 9 int
阅读全文
摘要:1 #include<stdio.h> 2 3 int main(void) 4 { 5 int n; 6 7 scanf("%d", &n); 8 9 for (int i = 1; i <= n; i++) 10 { 11 if (i % 2 == 1) 12 { 13 if ((i == n)
阅读全文
摘要:1 #include<stdio.h> 2 3 int main(void) 4 { 5 int bjt; 6 7 scanf_s("%d", &bjt); 8 9 int bjt_hour = bjt / 100; 10 int bjt_minute = bjt % 100; 11 12 int
阅读全文
摘要:1 #include 2 3 int main(void) 4 { 5 int x; 6 int n = 0; 7 8 scanf_s("%d", &x); 9 10 x = x / 10; 11 n++; 12 13 while (x > 0) 14 { 15 x = x / 10; 16...
阅读全文
摘要:1 #include<stdio.h> 2 3 int main(void) 4 { 5 double length; 6 int time; 7 double money; 8 9 scanf_s("%lf %d", &length, &time); 10 11 if (length <= 3) 12 { 13 money = 10; 14 } 15 else 16 { 17 if (lengt
阅读全文