- 博客(9)
- 资源 (2)
- 收藏
- 关注
转载 字符串反转
定义首尾两个指针,交换指针指向的值 char *revstr(char *str, size_t len) { char *start = str; char *end = str + len - 1; char ch; if (str != NULL) { while (start { ch = *start; *start++ = *e
2016-08-13 17:36:01
335
转载 输出杨辉三角
int main() { int s = 1; int h; int i, j; scanf("%d",&h); printf("1\n"); for (i = 2; i { printf("1 "); for (j = 1; j = i - 2; j++) printf("%d ",(s=(i-j)*s/j)); prin
2016-08-13 16:19:12
573
原创 13、 耶稣有13个门徒,其中有一个就是出卖耶稣的叛徒,请用排除法找出这位叛徒:13人围坐一圈,从第一个开始报号:1,2,3,1,2,3……,凡是报到“3”就退出圈子,最后留在圈内的人就是出卖耶稣的叛
运行有点差错,不知道错在哪,待解决 #define _CRT_SECURE_NO_WARNINGS #include #include #include typedef struct people { int number; struct people *next; }people, *ptrpeople; int main() { ptrpeople phea
2016-08-11 16:20:15
2489
原创 编写函数,将大小为10的数组里面的整数升序排列,并编写一个函数,使得插入一个数之后,数组里面的整数依然按照升序排列
int ascending_array(int *array,int size) { for (int i = 0; i { for (int j = 0; j { if (array[j]>array[j + 1]) { int temp = array[j]; array[j] = array[j+1]; array[j+1] = temp; } } }
2016-08-11 13:20:38
8299
原创 输入大于5位的正整数,实现输出它的位数,并且正向和逆向输出这个整数
int main() { char num_string[20]; gets(num_string); char *p = num_string; int count = 0; while ((*p)!='\0') { count++; p++; } for (int i = 0; i printf("%c",num_string[i]); printf("\n")
2016-08-11 12:29:15
1417
转载 字符串转换成整数
#include #include int atoi(char *s) { int t=0; while(*s){ t=t*10+*s-'0'; s++; } return(t); } int main () { char a[]="12345"; int n = atoi(a); printf("n=%d ",n); return 0; } /*
2016-08-11 12:03:39
416
原创 编制一个完成两个数的四则运算程序。如:用户输入34+56则输出结果90.00。要求运算结果保留两位小数,用户输入时一次将两个数和操作符输入。
int main() { int a; char b; int c; int result = 0; printf("请输入算术表达式:\n"); scanf("%d%c%d",&a,&b,&c); switch (b) { case '+': result = a + c; printf("%d", result); break; case '-': result = a
2016-08-11 11:09:57
9664
原创 system(pause)
system("pause")可以实现冻结屏幕,便于观察程序的执行结果; int main() { printf("Hello World!\n"); system("PAUSE"); system("CLS"); system("PAUSE"); return 0; } 运行之后如下图所示: 然后,按下enter之后 再次按下enter之后,如图
2016-08-10 20:35:30
55453
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅