基础c语言编程实例题,一些基础的C语言题目

1,一些基础的C语言题目1.10,12,Ai=2E2.while(n!=0)n=n/101)10,12,102)n,n/10上面的答案有错 。3,4题正确
2,c语言编程例题#include #include int main(int argc, char * argv[]){ int i, n; scanf("%d", &n); int * a = (int*)malloc(sizeof(int)*n); int * b = (int*)malloc(sizeof(int)*n); for (i=0;i
3 , 求解一道C语言基础编程题#include <stdio.h>void GetNums(const int n[3], int res[3])if (NULL == n || NULL == res)return;}memmove(res, n, sizeof(int) * 3);#define BACK_MOVE(src, dst) (src) += (dst >>= 1);BACK_MOVE(res[2], res[0]);BACK_MOVE(res[1], res[2]);BACK_MOVE(res[0], res[1]);#undef BACK_MOVE}int main(int argc, const char* const argv[])int n[3] =GetNums(n, n);for (int i = 0; i < 3; i++)printf("%d ", n[i]);}printf("\n");return 0;}原来3堆火柴的根数分别是:221412 根#include<stdio.h>int main()for(i=2; i>-1; i--)a[i]+=a[(i+1)%3];}for(j=0; j<3; j++)printf("%d ",a[j]);printf("\n");return 0;}【基础c语言编程实例题,一些基础的C语言题目】
4,c语言编程题目//第一题#include "stdio.h"double fun(int n){double result=1.0;while (n>1 && n<170)/*********found*********/result*=n--;/*********found*********/return result;}main(){int n;printf("Enter an integer: ");scanf("%d",&n);printf("\n\n%d!=%lg\n\n",n,fun(n));}//第二题#include #include void fun(int a, int b, long *c) { *c=a%10*100+a/10+b/10*10+b%10*1000; } main() { int a,b; long c; printf("Input a, b:"); scanf("%d%d", &a, &b); fun(a, b, &c); printf("The result is: %ld\n", c); }我的答案跟“C/C++”回答的差不多?。∪绻慊姑谎У街刚牖蚴椋以侔锬阈吹诙实奶饽浚ㄊ椤⒅刚攵疾挥茫 。〉谝惶?#include "stdio.h"double fun(int n){double result=1.0;while (n>1 && n<170)/*********found*********/result*=n--;//将--n改为n--/*********found*********/return result;//横线上填result}main(){int n;printf("Enter an integer: ");scanf("%d",&n);printf("\n\n%d!=%lg\n\n",n,fun(n));}第二题#include #include void fun(int a, int b, long *c) { int i,j,k,l; i=a/10;//a的十位数 j=a%10;//a的个位数 k=b/10;//b的十位数 l=b%10;//b的个位数 *c=i+100*j+10*k+1000*l; } main() { int a,b; long c; printf("Input a, b:"); scanf("%d%d", &a, &b); fun(a, b, &c); printf("The result is: %ld\n", c); }用递归做好一些第一题:result第二题:void fun(int a,int b,long *c){*c=(a%10)*1000+(b/10)*100+(a/10)*10+b%10;}72. void fun(char *s,char t[]){int i,j=0,n=strlen(s);for(i=0;i第一题 改错题(30分)函数fun的功能是: 计算整数n的阶乘 。【MODI1.C】#include "stdio.h"double fun(int n){double result=1.0;while (n>1 && n<170)/*********found*********/result*=n--;----->//--n;/*********found*********/return result;--->//_____;}main(){int n;printf("Enter an integer: ");scanf("%d",&n);printf("\n\n%d!=%ldg\n\n",n,fun(n));---->//\n\n",n,fun(n));}第二题 编程题(70分)函数fun的功能是: 将两个两位数的正整数a、b合并形成一个整数放在c中 。合并的方式是: 将a数的十位和个位数依次放在c数的个位和百位上, b数的十位和个位数依次放在c数的十位和千位上 。例如, 当a=45, b=12, 调用该函数后, c=2514 。【PROG1.C】#include #include void fun(int a, int b, long *c) { int d; d=b/10; d*=10; d+=a/10; d+=a%10*100; d+=b%10*1000; c=&d; } main() { int a,b; long c; printf("Input a, b:"); scanf("%d%d", &a, &b); fun(a, b, &c); printf("The result is: %ld\n", c);

    推荐阅读