东华复试OJ每日3题打卡·复盘85~87

基础85:假设所有的短号都是"6"+手机号的后5位,比如号码为13512345678的手机,对应的短号就是645678。给你一个11位长的手机号码,你找出对应的短号。

cpp 复制代码
#include <stdio.h>
#include <stdlib.h>

int main(){
    int circles;
    scanf("%d",&circles);
    getchar();  // 回收残留的换行符
    while(circles){
        char chars[15];
        fgets(chars,sizeof(chars),stdin);
        printf("6");
        for(int i=6;i<15;i++){
            if(chars[i] == '\0' || chars[i] == '\n')break;
            printf("%c",chars[i]);
        }
        printf("\n");
        circles--;
    }
    
    
    
}

基础86:对于给定的一个字符串,统计其中小写字母出现的次数。

cpp 复制代码
#include <stdio.h>
#include <stdlib.h>

int main(){
    int circles;
    scanf("%d",&circles);
    getchar();  // 回收残留的换行符
    while(circles){
        int ans=0;
        char chars[100];
        fgets(chars,sizeof(chars),stdin);
        for(int i=0;i<100;i++){
            if(chars[i] == '\0' || chars[i] == '\n')break;
            if(chars[i] >= 97 && chars[i]<=122)ans++;
        }
        printf("%d\n",ans);


        
    
        circles--;
    }
    
    
    
}

基础87:你的弟弟刚做完了"100以内数的加减法"这部分的作业,请你帮他检查一下。每道题目的格式为a+b=c或者a-b=c,其中a和b是作业中给出的,均为不超过100的非负整数;c是弟弟算出的答案,可能是不超过200的非负整数,也可能是单个字符"?",表示他不会算。

cpp 复制代码
#include <stdio.h>
#include <stdlib.h>

int  main(){
    char Question[15]={0};
    int Correct=0;
    while( fgets(Question, sizeof(Question), stdin) ){
        int numA=0,numB=0,ans;
        int operatorC;
        int firstOP=1;//检测到第一个运算符后,下次接收数据为第二个数
        for(int i=0;i<15;i++){
            if(Question[i]!='+' && Question[i]!='-'&& Question[i]!='='&&Question[i]!='?'){
                //不为以上四个符号时,当前为数字
                if(firstOP)numA = numA*10 + (Question[i] - '0');
                else numB = numB*10 + (Question[i] - '0');
            }
            else{
                if(Question[i]=='+'){
                    operatorC = 1;//1加
                    firstOP=0;
                }
                if(Question[i]=='-'){
                    operatorC = 2;//2减
                    firstOP=0;
                }
                if(Question[i]=='='){//检测到等于时进行计算
                    int Jindex=i+1;
                    int numC=0;
                    while(Question[Jindex] != '\n' && Question[Jindex] != '\0'){
                        if(Question[i]=='?'){
                            numC=-999;
                            break;
                        }
                        else numC=numC*10+(Question[Jindex] - '0');
                        Jindex++; 
                    }//得到numC
                    switch(operatorC){
                        case 1:ans = numA+numB;break;
                        case 2:ans = numA-numB;break;
                    }
                    if(numC==ans)Correct++;
                    break;
                }
            }
        }//for循环遍历一行每个字符
    
    }
    printf("%d\n",Correct);
    system("pause");
    return 0;
}


//接收数据的形式:一行为单位

ENIAC (see Figure 1A-1) contained 18,000 vacuum tubes and had a speed of several hundred multiplications per minute, but originally its program was wired into the processor and had to be manually altered. Later machines were built with program storage, based on the ideas of the Hungarian-American mathematician John von Neumann. The instructions, like the data, were stored within a "memory", freeing the computer from the speed limitations of the paper-tape reader during execution and permitting problems to be solved without rewiring the computer.

  • a speed of xx的速度,multiplications 乘法,wired into 内置/通过硬接线集成, execution 执行,permitting 允许。
  • 电子数字积分计算机具有18000个真空管和每分钟几百次乘法运算的速度,但是它的程序初始通过硬接线集成 在处理器中且需要手动修改。之后的机器都是基于冯诺依曼的程序存储的方法来构造。指令就像数据一样都存储在存储器中,让计算机从受到纸带阅读器的执行速度限制中释放出来,允许解决问题而无需重新布线计算机。

The use of the transistor in computers in the late 1950s marked the advent of smaller, faster, and more versatile logical elements than were possible with vacuum-tube machines. Because transistors use much less power and have a much longer life, this development alone was responsible for the improved machines called second-generation computers. Components became smaller, as did inter-component spacings, and the system became much less expensive to build.

  • transistor 晶体管,the late 1950s 20世纪50年代末,versatile 多用途/通用的,logical elements 逻辑元件,were possible with 通过成为可能,more A than B 与其说是B,不如说是A
  • 在20世纪50年代末,计算机中晶体管的使用标志着更小更快的到来,与其真空管机器,逻辑元件要更通用标志着比真空管机器所能实现的逻辑元件更小、更快、功能更强大的新一代逻辑元件的诞生 。因为晶体管功耗更低 和更长的寿命,仅凭 这一发展独自实现了足以制造出被称为第二代计算机的更好的机器。部件和内部部件间隔都变得更小,这一体系的构建变得更便宜。

Late in the 1960s the integrated circuit, or IC¹ (see Figure 1A-2), was introduced, making it possible for many transistors to be fabricated on one silicon substrate, with interconnecting wires plated in place2. The IC resulted in a further reduction in price, size, and failure rate. The microprocessor became a reality in the mid-1970s with the introduction of the large-scale integrated (LSI³) circuit and, later, the very large-scale integrated (VLSI 4) circuit (microchip), with many thousands of interconnected transistors etched into a single silicon substrate.

  • fabricate 制作,substrate 基底,interconnecting 互相连接,in place 在对的位置,etched 蚀刻
  • 在20世纪60年代末,引入了集成电路使得将许多晶体管制作在一块硅基板上成为可能,通过将互相连接的线路放在合适的位置。集成电路导致了在价格、尺寸和失败率进一步地降低。在20世纪70年代中期,微处理器成为现实,通过引入了蚀刻在一个单独硅基板上的大规模集成电路和更大规模的集成电路。这些芯片将成千上万个相互连接的晶体管蚀刻在单个硅基板上。
相关推荐
追随者永远是胜利者1 小时前
(LeetCode-Hot100)70. 爬楼梯
java·算法·leetcode·职场和发展·go
不想看见4042 小时前
Climbing Stairs 基本动态规划:一维--力扣101算法题解笔记
算法·leetcode·动态规划
陈天伟教授2 小时前
人工智能应用- 推荐算法:05.推荐算法的社会争议
算法·机器学习·推荐算法
追随者永远是胜利者2 小时前
(LeetCode-Hot100)49. 字母异位词分组
java·算法·leetcode·职场和发展·go
apcipot_rain2 小时前
原神“十盒半价”问题的兹白式建模分析
python·数学·算法·函数·数据科学·原神·数列
小刘的大模型笔记2 小时前
PPO与DPO:大模型对齐的两大核心算法,差异与选型全解析
算法
啊阿狸不会拉杆2 小时前
《计算机视觉:模型、学习和推理》第 1 章 - 绪论
人工智能·python·学习·算法·机器学习·计算机视觉·模型
Frostnova丶2 小时前
LeetCode 693. 交替位二进制数
算法·leetcode
_F_y2 小时前
递归搜索入门
算法