猫史档案馆


【社区里谁会C++】

用户:树林归来树林归来查看:7 回复:17 评论:7 创建时间:2022-07-14T12:12:24


【社区里谁会C++】


回复

上一页1 页 / 共 1下一页
乐观的暴风雀4vQd乐观的暴风雀4vQd

 

点赞0


评论


yee089yee089

@爵士OIer

点赞2


评论


姓梁monkey淡退姓梁monkey淡退

我会,能做几个最基础的小游戏出来,分享一下我做过的一个代码:摩斯密码翻译

#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<conio.h>
#include<Windows.h>
using namespace std;
string s,x="",a[26]={".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."},b[10]={"-----",".----","..---","...--","....-",".....","-....","--...","---..","----."};
bool f=false;
char c;
void gotoxy(int xpos, int ypos)
{
	COORD scrn;
	HANDLE hOuput = GetStdHandle(STD_OUTPUT_HANDLE);
	scrn.X = xpos; scrn.Y = ypos;
	SetConsoleCursorPosition(hOuput, scrn);
}
int main()
{
	int l,xl,q=0,n=2;
	cout<<"摩斯电码程序"<<endl<<"请问你是要加密还是解密:"<<endl<<"  1.加密"<<endl<<"  2.解密"<<endl;
	while(true)
	{
		c=getch();
		if(c=='H' && n>2)
		{
			n--;
		}
		if(c=='P' && n<3)
		{
			n++;
		}
		if(c=='\r')
		{
			break;
		}
		printf("\b ");
		gotoxy(2,n);
		printf("\b>");
	}
	gotoxy(0,5);
	if(n==2)
	{
		cout<<"请输入你的加密内容(暂不支持中文):";
		getline(cin,s);
		l=s.size();
		for(int i=0;i<l;i++)
		{
			if((s[i]<'0' || s[i]>'9') && ((s[i]<'a' ||s[i]>'z') && (s[i]<'A' ||s[i]>'Z')))
			{
				q=0;
				cout<<"/"<<s[i];
			}
			else
			{
				if(q==0)
				{
					q++;
				}
				else
		        {
		        	cout<<"/";
				}
			}
		    if(s[i]>='0' && s[i]<='9')
		    {
		    	xl=b[s[i]-'0'].size();
		    	for(int j=0;j<xl;j++)
		    	{
		    		cout<<b[s[i]-'0'][j];
				}
			}
			if(s[i]>='a' && s[i]<='z')
		    {
		    	xl=a[s[i]-'a'].size();
		    	for(int j=0;j<xl;j++)
		    	{
		    		cout<<a[s[i]-'a'][j];
				}
			}
		}
		cout<<"/";
	}
	else
	{
		cout<<"请输入你的电码:"; 
		getline(cin,s);
		l=s.size();
		for(int i=0;i<l;i++)
		{
			if(s[i]!='.' && s[i]!='-' && s[i]!='/')
			{
				cout<<s[i];
			}
			else if(s[i]=='/')
			{
				for(int j=0;j<26;j++)
				{
					if(x==a[j])
					{
						printf("%c",j+'a');
				        f=true;
				        break;
					}
				}
				if(!f);
				{
					for(int j=0;j<10;j++)
					{
						if(x==b[j])
						{
							printf("%d",j);
				        	break;
						}
					}
				}
				x="";	
			}
			else
			{
				if(x=="")
				{
					x=s[i];
				}
				else
				{
					x+=s[i];
				}
			}
		}
	}
}

操作:选择界面用上下键控制,Enter(回车)确定,然后输入即可

点赞0


评论


小萝卜cXsQ小萝卜cXsQ

我会,看帖:shequ.codemao.cn/community/468485

点赞0


评论


Cecilia_VentiCecilia_Venti

我不会,但我会Python,我可以教你

点赞0


评论


mhdLing314mhdLing314

我会

点赞0


评论


Vincent_xiaoboVincent_xiaobo

正在学

#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, s = 0;
	cin >> n;
	for(int x = 0; x <= n / 5; x++){
		for(int y = 0; y <= n / 2; y++){
			int z = n - x * 5 - y * 2;
			if(z >= 0) s++;
			
		}
	}
	cout << s;
	return 0;
}

点赞0


评论


不知道该叫啥的一只萌新不知道该叫啥的一只萌新

#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
vector<int> h[N],c[N];
int dis[N];
void SPFA(int s){
	memset(dis,0x3f,sizeof(dis));
	dis[s]=0;
	queue<int> q;
	q.push(s);
	
	while(!q.empty()){
		int x=q.front();q.pop();
		for(int i=0;i<(int)h[x].size();i++){
			int u=h[x][i];
			if(dis[u]>dis[x]+c[x][i]){
				dis[u]=dis[x]+c[x][i];
				q.push(u);
			}
		}
	}
}
int main(){
	h[0].push_back(1);
	c[0].push_back(1);
	h[1].push_back(5);
	c[1].push_back(2);
	h[0].push_back(5);
	c[0].push_back(0);
	SPFA(0);
	printf("%d",dis[5]?"我不会C++!":"我会C++!");
	return 0;
}

点赞1


评论


用户_869149用户_869149

一大堆人都会呢

点赞0


评论


TobylaiTobylai

OIer们都出来吧emotion_doge

点赞0


评论


果敢的胆小菇1Xzl果敢的胆小菇1Xzl

我在学

点赞0


评论


我戴圣也我戴圣也

个个都是大神

点赞0


评论


树林归来树林归来

#include <iostream>
#include <string>
using namespace std;

struct tWindow{
   int top,bottom,left,right;

};

tWindow winA,winB,temp;

tWindow indata(){
    cin>>temp.top>>temp.bottom>>temp.left>>temp.right;
    return temp;
}

int main(){
    winA = indata();
    winB = indata();
    temp.right = min(winA.right,winB.right);
    temp.left = max(winA.left,winB.left);
    temp.top = max(winA.top,winB.top);
    temp.bottom = min(winA.bottom,winB.bottom);
    int s = (temp.right - temp.left) * (temp.bottom - temp.top);
    if(temp.right <= temp.left || temp.bottom <= temp.top){
      s = 0;
    }
    cout<<s;
}

【输入】两个窗户的左右上下坐标。

【输出】两个窗户的重合面积,没有则输出0

示范:

10 100 20 60

60 160 50 200

输出:

400(重合面积)

 

点赞0


评论


星河非昨夜星河非昨夜

不会C++

只会C++++++

点赞0


评论


小鹿UUyM小鹿UUyM

我会!

点赞0


评论


白篮白篮

c++是什么,不知道,

点赞0


评论


树林归来树林归来

没想到这么多人会,报一下学了几年

点赞0


评论