用户:
陈夫托尔斯泰查看:13 回复:4 评论:13 创建时间:2022-07-13T17:02:45
做个智能小助手(1) #include<iostream>//导入打印,字符串头文件 #include<string> usingnamespacestd;//使用正确空间 stringname;//建个名字变量 intmain(){ cout<<"你好,我叫智能小助手陈夫!"<<endl;//引号里的随便改 cout<<"你叫什么?"<<endl; cin>>name;//问问 cout<<"你好!"<<name<<"同志"<<endl; return0; } 完成!imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E5%8E%89%E5%AE%B3%E4%BA%86.gif"alt="emotion_编程猫_厉害了"
yee089#include<bits/stdc++.h>
using namespace std;
int main(){
int a[2]={0,0},cnt=0;
char ch;
while(ch=getchar()){
if(ch=='+'){
cnt++;continue;
}
if(ch=='\n'){
cout<<a[0]+a[1]<<'\n';
return 0;
}
else{
a[cnt] = a[cnt]*10+ch-'0';
}
}
return 0;
}
点赞0
评论
#include <iostream>
using namespace std;
int main(){
char s[100];
int n = 0,num1 = 0,num2 = 0;
while((s[n] = getchar()) != '+'){
num1 = num1 * 10 + (s[n] - '0');
n++;
}
while((s[n] = getchar()) != '\n'){
num2 = num2 * 10 + (s[n] - '0');
n++;
}
cout<<num1 + num2<<endl;
}点赞0
评论
yee089#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
scanf("%d+%d",&a,&b);
cout<<a+b;
return 0;
}
点赞0
评论