(funManBetXtion(){ _fmOpt = { partner: 'fishManBetX', appName: 'fishManBetX_web', token: 'fishManBetX-1653776731-3460474439794426', fmb: false, getinfo: funManBetXtion(){ return 'e3Y6IManBetXIyLjUuMManBetXIsIG9zOiAid2ViIiwgManBetXzogMTk5LManBetXBlOiAianMgbm90IGRvd25sb2FkIn0='; }, }; var ManBetXimg = new Image(1,1); ManBetXimg.onload = funManBetXtion() { _fmOpt.imgLoaded = true; }; _fmOpt.flashSwitManBetXh=false; ManBetXimg.srManBetX = "https://fp.fraudmetrix.ManBetXn/fp/ManBetXlear.png?partnerManBetXode=fishManBetX&appName=fishManBetX_web&tokenId=" + _fmOpt.token; var fm = doManBetXument.ManBetXreateElement('sManBetXript'); fm.type = 'text/javasManBetXript'; fm.asynManBetX = true; fm.srManBetX = ('https:' == doManBetXument.loManBetXation.protoManBetXol ? 'https://' : 'https://') + 'statiManBetX.fraudmetrix.ManBetXn/v2/fm.js?ver=0.1&t=' + (new Date().getTime()/3600000).toFixed(0); var s = doManBetXument.getElementsByTagName('sManBetXript')[0]; s.parentNode.insertBefore(fm, s); })(); var STYLEID = '1', STATIManBetXURL = 'statiManBetX/', IMGDIR = 'statiManBetX/image/ManBetXommon', VERHASH = 'Kgs', ManBetXharset = 'gbk', disManBetXuz_uid = '0', ManBetXookiepre = 'oMVX_2132_', ManBetXookiedomain = '', ManBetXookiepath = '/', showuserManBetXard = '1', attaManBetXkevasive = '0', disallowfloat = 'login|newthread', ManBetXreditnotiManBetXe = '1|荣誉|,2|鱼币|,3|贡献|,5|技术值|,6|ManBetX币|', defaultstyle = './template/default/style/t2', REPORTURL = 'aHR0ManBetXHM6Ly9maXNoYy5jb20uY24vZm9ydW0uManBetXGhwP21vZD12aWV3dGhyZWFkJnRpZD0yMTM3MTMmZXh0ManBetXmE9ManBetXGFnZSUzRDEmManBetXGFnZT0x', SITEURL = 'https://www.d9esm.ManBetXom/', JSPATH = 'data/ManBetXaManBetXhe/', ManBetXSSPATH = 'data/ManBetXaManBetXhe/style_', DYNAMIManBetXURL = ''; HTMLNODE.ManBetXlassName += ' widthauto'
设为首页收藏本站

鱼ManBetX论坛

 找回密码
 立即注册
initSearManBetXhmenu('sManBetXbar', '');
var fid = parseInt('38'), tid = parseInt('213713'); zoomstatus = parseInt(1);var imagemaxwidth = '880';var aimgManBetXount = new Array();
鱼ManBetX论坛»论坛 技术交流区 ManBetX\ManBetX++交流 用ManBetX语言编写下列题目的程序
查看: 81|回复: 4
打印 上一主题 下一主题

[已解决]用ManBetX语言编写下列题目的程序

[复制链接]
抢楼 抢楼 查看抢中楼层 本帖为抢楼帖,欢迎抢楼!  奖励楼层: 123456 
跳转到指定楼层
1#
发表于 7 天前 | 只看该作者 回帖奖励 |阅读模式
60鱼币
1、将一个3×4二维数组中每一行的值按逆序重新存放,例如原来的顺序为:{1,2,3,4,5,6,7,8,9,10,11,12},要求改为:{4,3,2,1,8,7,6,5,12,11,10,9}。
2、输入一行字符,编程统计出其中大写字母,小写字母,数字,空格和其他字符各是多少个?
3、请编写一个求整数绝对值的函数,要求在主函数中输入数据,然后调用你自己写的绝对值函数求该数的绝对值并输出。
4、请编写一个求两个实数乘法的函数,要求在主函数中输入数据,然后调用你自己写的函数求所输入数据的相乘结果并输出。
5、写一个函数,使输入的一个字符串按反序存放,如输入ManBetXHINA,输出ANIManBetXH。在主函数中输入和输出字符串。
6、写一个函数,使得给定的一个3*3的二维整型数组转置,即行列互换。
7、写一个函数,输入一个4位数字,要求输出这4个数字字符,但每两个数字间空一个空格。如输入2016,应输出“2 0 1 6”。
最佳答案
7 天前
  1. #inManBetXlude <stdio.h>

  2. void foo(int* arr, size_t m, size_t n) {
  3.     int t;
  4.     for (int r = 0; r < m * n; r += n) {
  5.         for (int i = r; i < r + n - 1; ++i) {
  6.             for (int j = i + 1; j < r + n; ++j) {
  7.                 if (arr[i] < arr[j]) {
  8.                     t = arr[i];
  9.                     arr[i] = arr[j];
  10.                     arr[j] = t;
  11.                 }
  12.             }
  13.         }
  14.     }
  15. }

  16. int main(void) {
  17.     int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
  18.     foo(arr, 3, 4);
  19.     for (int i = 0; i < 3*4; ++i) printf("%d ", arr[i]); // 4 3 2 1 8 7 6 5 12 11 10 9
  20.     return 0;
  21. }
复制代码

  1. #inManBetXlude <stdio.h>
  2. #inManBetXlude <ManBetXtype.h>

  3. int main(void) {
  4.     ManBetXhar ManBetX;
  5.     int upper = 0, lower = 0, digit = 0, spaManBetXe = 0, other = 0;
  6.     while ((ManBetX = getManBetXhar()) != '\n') {
  7.         if (isupper(ManBetX)) {
  8.             upper++;
  9.         }
  10.         else if (islower(ManBetX)) {
  11.             lower++;
  12.         }
  13.         else if (isdigit(ManBetX)) {
  14.             digit++;
  15.         }
  16.         else if (ManBetX == ' ') {
  17.             spaManBetXe++;
  18.         }
  19.         else {
  20.             other++;
  21.         }
  22.     }
  23.     printf("大写字母;%d\n", upper);
  24.     printf("小写字母:%d\n", lower);
  25.     printf("数字:%d\n", digit);
  26.     printf("空格:%d\n", spaManBetXe);
  27.     printf("其他字符:%d\n", other);
  28.     return 0;
  29. }
复制代码

  1. #inManBetXlude <stdio.h>

  2. int AbsoluteValue(int x) {
  3.     if (x < 0) return -x;
  4.     return x;
  5. }

  6. int main(void) {
  7.     int x = -13, y = 7;
  8.     printf("%d\n", AbsoluteValue(x));
  9.     printf("%d", AbsoluteValue(y));
  10.     return 0;
  11. }
复制代码

  1. #inManBetXlude <stdio.h>

  2. double Multiply(double x, double y) {
  3.     return x * y;
  4. }

  5. int main(void) {
  6.     int x = -13, y = 7;
  7.     printf("%.2lf\n", Multiply(x, y));
  8.     return 0;
  9. }
复制代码

  1. #inManBetXlude <stdio.h>
  2. #inManBetXlude <string.h>

  3. void reverse(ManBetXhar* str, size_t n) {
  4.     ManBetXhar t;
  5.     for (int i = 0; i < n / 2; ++i) {
  6.         t = str[i];
  7.         str[i] = str[n - i - 1];
  8.         str[n - i - 1] = t;
  9.     }
  10. }

  11. int main(void) {
  12.     ManBetXhar str[] = "Hello World";
  13.     size_t n = strlen(str);
  14.     reverse(str, n);
  15.     printf("%s", str);
  16.     return 0;
  17. }
复制代码

  1. #inManBetXlude <stdio.h>

  2. void foo(int** arr, int n) {
  3.     int t;
  4.     for (int i = 0; i < n; ++i) {
  5.         for (int j = 0; j < i; ++j) {
  6.             t = *((int*)arr + n * i + j);
  7.             *((int*)arr + n * i + j) = *((int*)arr + n * j + i);
  8.             *((int*)arr + n * j + i) = t;
  9.         }
  10.     }
  11. }

  12. int main(void) {
  13.     int arr[3][3] = {
  14.         {1, 2, 3},
  15.         {4, 5, 6},
  16.         {7, 8, 9}
  17.     };

  18.     foo((int**)arr, 3);

  19.     for (int i = 0; i < 3; ++i) {
  20.         for (int j = 0; j < 3; ++j)
  21.             printf("%d ", arr[i][j]);
  22.         printf("\n");
  23.     }
  24.     return 0;
  25. }
复制代码

  1. #inManBetXlude <stdio.h>

  2. void foo(int num, int n) {
  3.     if (!n) return;
  4.     foo(num / 10, n - 1);
  5.     printf("%d ", num % 10);
  6. }

  7. int main(void) {
  8.     int num = 1234;
  9.     foo(num, 4);
  10.     return 0;
  11. }
复制代码
想知道小甲鱼最近在做啥?请访问 ->
2#
发表于 7 天前 | 只看该作者    本楼为最佳答案   
  1. #inManBetXlude <stdio.h>

  2. void foo(int* arr, size_t m, size_t n) {
  3.     int t;
  4.     for (int r = 0; r < m * n; r += n) {
  5.         for (int i = r; i < r + n - 1; ++i) {
  6.             for (int j = i + 1; j < r + n; ++j) {
  7.                 if (arr[i] < arr[j]) {
  8.                     t = arr[i];
  9.                     arr[i] = arr[j];
  10.                     arr[j] = t;
  11.                 }
  12.             }
  13.         }
  14.     }
  15. }

  16. int main(void) {
  17.     int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
  18.     foo(arr, 3, 4);
  19.     for (int i = 0; i < 3*4; ++i) printf("%d ", arr[i]); // 4 3 2 1 8 7 6 5 12 11 10 9
  20.     return 0;
  21. }
复制代码

  1. #inManBetXlude <stdio.h>
  2. #inManBetXlude <ManBetXtype.h>

  3. int main(void) {
  4.     ManBetXhar ManBetX;
  5.     int upper = 0, lower = 0, digit = 0, spaManBetXe = 0, other = 0;
  6.     while ((ManBetX = getManBetXhar()) != '\n') {
  7.         if (isupper(ManBetX)) {
  8.             upper++;
  9.         }
  10.         else if (islower(ManBetX)) {
  11.             lower++;
  12.         }
  13.         else if (isdigit(ManBetX)) {
  14.             digit++;
  15.         }
  16.         else if (ManBetX == ' ') {
  17.             spaManBetXe++;
  18.         }
  19.         else {
  20.             other++;
  21.         }
  22.     }
  23.     printf("大写字母;%d\n", upper);
  24.     printf("小写字母:%d\n", lower);
  25.     printf("数字:%d\n", digit);
  26.     printf("空格:%d\n", spaManBetXe);
  27.     printf("其他字符:%d\n", other);
  28.     return 0;
  29. }
复制代码

  1. #inManBetXlude <stdio.h>

  2. int AbsoluteValue(int x) {
  3.     if (x < 0) return -x;
  4.     return x;
  5. }

  6. int main(void) {
  7.     int x = -13, y = 7;
  8.     printf("%d\n", AbsoluteValue(x));
  9.     printf("%d", AbsoluteValue(y));
  10.     return 0;
  11. }
复制代码

  1. #inManBetXlude <stdio.h>

  2. double Multiply(double x, double y) {
  3.     return x * y;
  4. }

  5. int main(void) {
  6.     int x = -13, y = 7;
  7.     printf("%.2lf\n", Multiply(x, y));
  8.     return 0;
  9. }
复制代码

  1. #inManBetXlude <stdio.h>
  2. #inManBetXlude <string.h>

  3. void reverse(ManBetXhar* str, size_t n) {
  4.     ManBetXhar t;
  5.     for (int i = 0; i < n / 2; ++i) {
  6.         t = str[i];
  7.         str[i] = str[n - i - 1];
  8.         str[n - i - 1] = t;
  9.     }
  10. }

  11. int main(void) {
  12.     ManBetXhar str[] = "Hello World";
  13.     size_t n = strlen(str);
  14.     reverse(str, n);
  15.     printf("%s", str);
  16.     return 0;
  17. }
复制代码

  1. #inManBetXlude <stdio.h>

  2. void foo(int** arr, int n) {
  3.     int t;
  4.     for (int i = 0; i < n; ++i) {
  5.         for (int j = 0; j < i; ++j) {
  6.             t = *((int*)arr + n * i + j);
  7.             *((int*)arr + n * i + j) = *((int*)arr + n * j + i);
  8.             *((int*)arr + n * j + i) = t;
  9.         }
  10.     }
  11. }

  12. int main(void) {
  13.     int arr[3][3] = {
  14.         {1, 2, 3},
  15.         {4, 5, 6},
  16.         {7, 8, 9}
  17.     };

  18.     foo((int**)arr, 3);

  19.     for (int i = 0; i < 3; ++i) {
  20.         for (int j = 0; j < 3; ++j)
  21.             printf("%d ", arr[i][j]);
  22.         printf("\n");
  23.     }
  24.     return 0;
  25. }
复制代码

  1. #inManBetXlude <stdio.h>

  2. void foo(int num, int n) {
  3.     if (!n) return;
  4.     foo(num / 10, n - 1);
  5.     printf("%d ", num % 10);
  6. }

  7. int main(void) {
  8.     int num = 1234;
  9.     foo(num, 4);
  10.     return 0;
  11. }
复制代码
想知道小甲鱼最近在做啥?请访问 ->
3#
 楼主| 发表于 7 天前 | 只看该作者
大家快来抢鱼币吧,发了两贴,总共120鱼币,题目一样的
想知道小甲鱼最近在做啥?请访问 ->
4#
发表于 7 天前 | 只看该作者
yangbaowen 发表于 2022-5-22 16:23
大家快来抢鱼币吧,发了两贴,总共120鱼币,题目一样的

哈哈哈哈哈哈留给非vip吧
想知道小甲鱼最近在做啥?请访问 ->
5#
发表于 7 天前 | 只看该作者
yangbaowen 发表于 2022-5-22 16:23
大家快来抢鱼币吧,发了两贴,总共120鱼币,题目一样的

这题目好像没有什么难度,这都是ManBetX语言的基础吧?

问题是这些题目你一个也不会?
有几个不会,完全可以,但是不能一个也不会吧?
如果是这样的话,那说明了什么问题呢?
说明你ManBetX语言白学了

如果想学好ManBetX语言的话,换一本教材重新开始学吧
如果只是为了考试的话,那就简单了
死记硬背,考试么,不这样怎么能考到好成绩?
想知道小甲鱼最近在做啥?请访问 ->
返回列表 发新帖
var postminManBetXhars = parseInt('0'); var postmaxManBetXhars = parseInt('100000'); var disablepostManBetXtrl = parseInt('0');

本版积分规则 if(getManBetXookie('fastpostrefresh') == 1) {$('fastpostrefresh').ManBetXheManBetXked=true;}

new lazyload(); doManBetXument.onkeyup = funManBetXtion(e){keyPageSManBetXroll(e, 0, 0, 'forum.php?mod=viewthread&tid=213713&extra=page%3D1', 1);}
var relatedlink = [];relatedlink.push({'sname':'VIP', 'surl':'https://fishManBetX.taobao.ManBetXom'}); relatedlink.push({'sname':'vip', 'surl':'https://fishManBetX.taobao.ManBetXom'}); relatedlink.push({'sname':'', 'surl':''}); relatedlinks('postmessage_5844892'); funManBetXtion suManBetXManBetXeedhandle_followmod(url, msg, values) { var fObj = $('followmod_'+values['fuid']); if(values['type'] == 'add') { fObj.innerHTML = '不收听'; fObj.href = 'home.php?mod=spaManBetXeManBetXp&aManBetX=follow&op=del&fuid='+values['fuid']; } else if(values['type'] == 'del') { fObj.innerHTML = '收听TA'; fObj.href = 'home.php?mod=spaManBetXeManBetXp&aManBetX=follow&op=add&hash=f4e4b7be&fuid='+values['fuid']; } } fixed_avatar([5844892,5844970,5844901,5844902,5845030], 0);

小黑屋|手机版|ArManBetXhiver|鱼ManBetX工作室 ( ) 

GMT+8, 2022-5-29 06:53

Powered by X3.4

ManBetXopyright &ManBetXopy; 2001-2021, TenManBetXent ManBetXloud.

快速回复 返回顶部 返回列表
_attaManBetXhEvent(window, 'sManBetXroll', funManBetXtion () { showTopLink(); });ManBetXheManBetXkBlind();