【笔试题】Week04
来源:互联网 发布:淘宝水印怎么勾选 编辑:程序博客网 时间:2024/05/31 19:11
作业一
#include <stdio.h>#include <stdlib.h>/**输入一行字符,统计字母、空格、数字和其他字符的个数*/int main(){ char str[30]; gets(str); int i = 0; int cntLetter = 0; int cntSpace = 0; int cntNum = 0; int cntOther = 0; for(i = 0;str[i] != '\0' ;i++) { if( (str[i] > 'a' && str[i] < 'z') || (str[i] > 'A' && str[i] < 'Z') ) { cntLetter++; }else if(str[i] == ' ') { cntSpace++; }else if(str[i] > '0' && str[i] < '9') { cntNum++; }else { cntOther++; } } printf("字母的个数为:%d\n空格的个数为:%d\n数字的个数为:%d\n其他字符的个数为:%d",cntLetter,cntSpace,cntNum,cntOther); return 0;}
作业二
#include <stdio.h>#include <stdlib.h>/**1-1/2+1/3-1/4+……+1/99-1/100*/int main(){ double sum = 0; int num = 1; for(;num <=100 ;num++) { if(num % 2 !=0 ){ sum+=1.0/num; }else sum-=1.0/num; } printf("1-1/2+1/3-1/4+......+1/99-1/100=%lf",sum); return 0;}
作业三
#include <stdio.h>#include <stdlib.h>#define r 3#define c 3//矩阵转置int main(){ int a[r][c]; int b[c][r]; int i = 0; int j = 0 ; for(i = 0;i < r;i ++) { for(j = 0;j < c;j ++) { scanf("%d",&a[i][j]);//矩阵输入 b[j][i] = a[i][j];//实现矩阵转置 } } for(i = 0;i < c;i++) { for(j = 0;j < r;j++) { printf("%d ",b[i][j]); } printf("\n"); } return 0;}
阅读全文
0 0
- 【笔试题】Week04
- 【Java笔记】Week04 -- 面向对象
- 算法分析与设计week04--55.Jump Game
- 算法分析与设计week04--45.Jump Game II
- 笔试题
- 笔试题
- 笔试题
- 笔试题
- 笔试题
- 笔试题
- 笔试题
- 笔试题
- 笔试题
- 笔试题
- 笔试题
- 笔试题
- 笔试题
- 笔试题
- TCP_Socket及源代码01
- cxf webservice 完整例子
- 迅雷创始人程浩:人工智能创业的6大核心问题
- mac下安装mysql5.7.18,连接出现Access denied for user 'root'@'localhost' (using password: YES)
- 树上的 DP
- 【笔试题】Week04
- 北交大安全知识培训及考试平台真牛!
- 与dalao学校的联hu考ce(10.27)
- Android事件分发机制的图片总结(下)
- python-核心知识思维导图
- 44. Wildcard Matching
- javascript:history.go()和History.back()的区别(转载)
- 警告!NSA “永恒之蓝” 勒索蠕虫全球爆发,已波及 99 个国家 | 雷锋早报
- 【安全开机指南】安全专家三招教你防御WannaCry 勒索病毒