参考代码1001-1010
1001 Hello,World!
1 #include <iostream> 2 using namespace std; 3 int main() 4 { 5 cout<<"Hello,World!"<<endl; 6 return 0; 7 }
1002 输出第二个整数
1 #include <iostream> 2 using namespace std; 3 int main() 4 { 5 int a,b,c; 6 cin>>a>>b>>c; 7 cout<<b<<endl; 8 return 0; 9 }
1003 重要的事情说三遍
1 #include <bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 cout<<"父亲节快乐!"<<endl; 6 cout<<"父亲节快乐!"<<endl; 7 cout<<"父亲节快乐!"<<endl; 8 return 0; 9 }
1004 字符三角形
1 #include <bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 char a; 6 cin>>a; 7 cout<<" "<<a<<endl; 8 cout<<" "<<a<<a<<a<<endl; 9 cout<<a<<a<<a<<a<<a<<endl; 10 return 0; 11 }
1005 A+B -1
1 #include <bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 int a,b; 6 cin>>a>>b; 7 cout<<a<<'+'<<b<<'='<<a+b<<endl; 8 return 0; 9 }
1006 长方形的周长和面积
#include <bits/stdc++.h> using namespace std; int main() { int a,b,c,d; cin>>a>>b; c=(a+b)*2; d=a*b; cout<<c<<' '<<d<<endl; return 0; }
1007 数字之和
1 #include<iostream> 2 using namespace std; 3 int main(){ 4 int n,a,b,c; 5 cin >> n; 6 a = n % 10; 7 b = n / 10 % 10; 8 c = n / 100; 9 cout << a + b + c << endl; 10 return 0; 11 }
1008 (a+b)/c的值
1 #include <bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 int a,b,c; 6 cin>>a>>b>>c; 7 cout<<(a+b)/c<<endl; 8 return 0; 9 }
1009 买苹果
1 #include <bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 int a,b,c; 6 cin>>a; 7 b=a/6; 8 c=a%6; 9 cout<<b<<" "<<c<<endl; 10 return 0; 11 }
1010 瑜伽运动计时
1 #include <bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 int x,a,b,c; 6 cin>>x; 7 a=x/3600; 8 b=x%3600/60; 9 c=x%60; 10 cout<<a<<" "<<b<<" "<<c<<endl; 11 return 0; 12 }