#define_CRT_SECURE_NO_WARNINGS1#include<string.h>#include<stdio.h>intmain(){int n =0;int jifen =1;int sum =0;int i =1;printf("请输入想算的阶乘数n\n");scanf("%d",&n);for(i =1;i<=n; i++){
jifen = jifen * i;
sum += jifen;}printf("%d %d\n",jifen,sum);return0;}
2,编写代码,演示多个字符从两端移动,向中间汇聚。
#define_CRT_SECURE_NO_WARNINGS1#include<string.h>#include<stdio.h>#include<windows.h>intmain(void){char arr1[]="wekcome to china!";char arr2[]="*****************";int left =0;int right =strlen(arr1)-1;while(left<=right){
arr2[left]= arr1[left];
arr2[right]= arr1[right];printf("%s\n",arr2);Sleep(1000);system("cls");//清空屏幕
left++;
right--;}if(left >right)printf("%s\n", arr2);return0;}