题目描述
1.输出一个由 n 行 m 列一共 n*m 个符号组成的图案,第一个 符号是"#" , 接下来交替出现"@"和"#"。
输入格式
无
输出格式
无
输入输出样例
输入 #1
4 5
输出 #1
#@#@#
@#@#@
#@#@#
@#@#@
输入 #2
3 6
输出 #2
#@#@#@
#@#@#@
#@#@#@
2.题目描述
假设有一群人买一件物品,如果每个人出 a 元,则所付的总金额比物品的价格多了 x 元;如果每个人出 a−1 元,则所付的总金额比物品的价格少了 y元。给定 a,x,y,求人数及物品的价格。
输入格式
单独一行:三个整数:a, x 及 y。
输出格式
两个整数:第一个整数表示参与的人数,第二个整数表示物品的价格,中间用一个空格分开。
输入输出样例
输入 #1
8 3 4
输出 #1
7 53
输入 #2
5 2 6
输出 #2
8 38
说明/提示
数据范围:
1≤a≤1000
1≤x≤1000
1≤y≤1000
第一题
#include<bits/stdc++.h>
using namespace std;
int main(){
int a, b;
cin >> a >> b;
bool c = true;
for (int i = 1; i <= a; ++i) {
for (int j = 1; j <= b; ++j) {
if (c){
c = false;
cout << "#";
} else{
c = true;
cout <<"@";
}
}
cout << endl;
}
return 0;
}
第二题
#include<bits/stdc++.h>
using namespace std;
int main(){
int a, b, c;
cin >> a >> b >> c;
cout << b+c << " " << (b+c)*a-b<< endl;
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(){
int a, x, y;
cin >> a >> x >> y;
cout << x+y << " " << (x+y)*a-y;
return 0;
}
第一题:
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m,i,j,f=1;
cin >>n >> m;
for(i=0;i<n;i++){
for(j=0;j<m;j++){
if(f==1)
printf("#");
else
printf("@");
f=-f;
}
printf("\n");
}
return 0;
}