东华复试OJ每日3题打卡·复盘100~102

基础100:根据一个正整数n,求出从100开始从小到大的第n个纯粹合数。

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


int func(int num){
	if(num<=9)return 0;
	 //0.确定位数
	int len=0;
	for(int i=num;i>0;i/=10){
		len++;
	}
	//1.减数 
	int Jian=1;
	for(int i=1;i<len;i++)Jian*=10;
	
	//2.减掉高位
	while(num>=Jian)num-=Jian;
	return num; 
	
	
}


int main(){
    int n=0;
    char Hang[10];
    
    while( fgets(Hang,sizeof(Hang),stdin) ){
    	n=0;
    	Hang[ strcspn(Hang,"\n")]='\0';
    	for(int i=0;i<strlen(Hang);i++){
    		n = n*10+(Hang[i] - '0');
		}

    	int num=100;
        int count=1;
        while(count < n){
            num++;
            //检测是否为合数
            int Yes=0;//是否为合数
			 
            int temp=num;
            while(temp>0){
            	int HasYinZi=0;
            	if(temp<4){
            		Yes=0;
            		break;
				}
				else {
					for(int i=2;i<=temp/2;i++){
		                if(temp%i==0){
		                    HasYinZi=1;
		                    break;
		                }
            		}
	            	if(HasYinZi==0){
	            		Yes=0;
	            		break;
					}
				}
				if(HasYinZi)Yes=1;
				//去掉高位
				temp = func(temp);
			}//逐位循环 
            if(Yes)count++;
        }//算法
        printf("%d\n",num);
        
    }
}

基础101:输入一串数字,找出其中最长的不超过4个字符的质数子串。若有多个答案,则找出其中数值最大的一个。

cpp 复制代码
//输入一行数字,找到连续数字组成最大的质数

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int Check(int num){
	if(num==2||num==3) return 1;
	if(num%2==0)return 0;
	else{
		for(int i=3;i<=num/2;i+=2){
			if(num%i==0)return 0;
		}
		return 1;
	} 
}



int main(){
    //数字串的长度不超过20
    char Hang[30];
    while( fgets(Hang,sizeof(Hang),stdin) ){
        Hang[strcspn(Hang,"\n")] = '\0';
        //printf("%s\n",Hang);
        //辅助变量

        int ans=0;
        //1.遍历每位数字,找到其能与之后数字组成的最长最大质数串
        
        for(int i=0;i<strlen(Hang);i++){
            int temp=(Hang[i] - '0');
            //对单独一个数进行校验 
            if(Check(temp)){
                //如果是质数,则比较是否大于记录
                if(temp>ans){
                    ans = temp;
                }
            }
            for(int j=i+1;j<i+4;j++){
                temp = temp*10 + (Hang[j] - '0');
                //检验是否为质数
                if(Check(temp)){
                    //如果是质数,则比较是否大于记录
                    if(temp>ans){
                        ans = temp;
                    }
                }
            }
        }//遍历每个数字,并构成质数串

        printf("%d\n",ans);
        
    }//每次数据的循环
}

基础102:一串以'@'为结束标志的字符串,从左至右对其进行翻译,若字符串中当前字符是整数n(0≤n≤9),则表示将后一个字符重复n+1次,不论后一个字符是否为数字,且后一个字符无需再次翻译;若当前字符非数字,则表示自己,无需翻译,直接输出即可。

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

int main(){
    char Hang[15];
    while(fgets(Hang,sizeof(Hang),stdin)){
        Hang[strcspn(Hang,"\n")] = '\0';
        int count = 0;
        
        
        int repeat = 0;
        for(int i=0;i<strlen(Hang);i++){
            if(repeat){
            	repeat++;
               while(repeat){
                   printf("%c",Hang[i]);
                   repeat--; 
                   count++;
                   if(count%3==0 && !(i==strlen(Hang)-1 && repeat==0) )printf(" ");
                   
               }
            }
            else{
                if(Hang[i]>='0' && Hang[i]<='9')repeat=Hang[i]-'0';
                else{
                	printf("%c",Hang[i]);
                	count++;
                   if(count%3==0 && !(i==strlen(Hang)-1 && repeat==0) )printf(" ");
				} 
            }
        }
        printf("\n");
    }
}

Computer scientists continue to expand the frontiers of computer and information systems by pioneering the designs of more complex, reliable, and powerful computers; enabling networks of computers to efficiently exchange vast amounts of information; and seeking ways to make computers behave intelligently. As computers become an increasingly integral part of modern society, computer scientists strive to solve new problems and invent better methods of solving current problems.

  • pioneering 开创/引领做先锋,integral 内在的/不可或缺的
  • 计算机科学家们继续探索计算机和信息系统的边界,引领着更复杂、更可信赖、更强大的计算机设计,他们使计算机网络能高效地交换大量信息并探索让计算机表现智能化的方法。随着计算机在现代社会中越来越不可分割,计算机科学家努力解决新问题和发明解决当前问题的更优解。

The goals of computer science range from finding ways to better educate people in the use of existing computers to highly speculative research into technologies and approaches that may not be viable for decades. Underlying all of these specific goals is the desire to better the human condition today and in the future through the improved use of information.

  • speculative 推测的/冒险的、highly speculative 纯理论推测的
  • 计算机科学的目标范围从找到更好地指导人们使用现有计算机的方法,到可能数十年都不可行的技术与方法中进行高度推测性的研究 。隐藏在所有特定目标下的是渴望改善人类当今与未来的境况 通过在未来对信息的使用改进更好地利用信息

Computer science is a combination of theory, engineering, and experimentation. In some cases, a computer scientist develops a theory, then engineers a combination of computer hardware and software based on that theory, and experimentally tests it. An example of such a theory-driven approach is the development of new software engineering tools that are then evaluated in actual use. In other cases, experimentation may result in new theory, such as the discovery that an artificial neural network exhibits behavior similar to neurons in the brain, leading to a new theory in neurophysiology.

  • neurophysiology 神经生理学
  • 计算机科学结合了理论、工程学和实验。在一些情况下,计算机科学家构建理论模型,然后基于该理论设计并构建计算机 硬件和软件的计算机结合体,最后实验测试该机器。这样一个理论驱动的方法的一个例子先开发 新软件工程工具的开发然后在实际使用中 并评估实际使用情况。在其他情况下,实验会引发新理论的发现,例如人工神经网络表现出与大脑里的神经元相似的行为,便催生了神经生理学的新理论
相关推荐
三品吉他手会点灯10 小时前
C语言学习笔记 - 20.C编程预备计算机专业知识 - 变量为什么必须的初始化【重点】
c语言·笔记·学习
sakiko_11 小时前
UIKit学习笔记1-创建项目(使用UIKit)、使用组件
笔记·学习
生信碱移11 小时前
PACells:这个方法可以鉴定疾病/预后相关的重要细胞亚群,作者提供的代码流程可以学习起来了,甚至兼容转录组与 ATAC 两种数据类型!
人工智能·学习·算法·机器学习·数据挖掘·数据分析·r语言
星幻元宇VR13 小时前
VR航空航天科普设备【VR时空直升机】
科技·学习·安全·生活·vr
_李小白13 小时前
【android opencv学习笔记】Day 2: Mat类(图片数据结构体)
android·opencv·学习
harder32114 小时前
RMP模式的创新突破
开发语言·学习·ios·swift·策略模式
程序猿乐锅15 小时前
【Tilas|第三篇】多表SQL语句
数据库·经验分享·笔记·学习·mysql
徐某人..15 小时前
基于i.MX6ULL平台的智能网关系统开发
arm开发·c++·单片机·qt·物联网·学习·arm
AOwhisky16 小时前
Kubernetes 学习笔记:集群管理、命名空间与 Pod 基础
linux·运维·笔记·学习·云原生·kubernetes
光影少年16 小时前
大屏页面,一次多个请求,请求加密导致 点击 全局时间选择器 时出现卡顿咋解决(面板收起会延迟1~2秒)
前端·javascript·vue.js·学习·前端框架·echarts·reactjs