竞赛
考级
代码如下:
可用三目运算符 跟别人应该不一样 别不信,确实能AC ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
思路分析 这道题主要考验的是我们对于判断的掌握,只要掌握了判断,这道题基本上没问题 答案 提问时间,随便提问吧
很难 简单
给定三个整数 a,b,c,请筛选出大于 0 的数字 输入格式 输入一行三个整数 a,b,c。 输出格式 输出多行,依次将 a,b,c 中大于 0 的数输出并换行。 参考代码
这题只有正整数a, b, c三个变量,给定数组三个下标即可
这道题目用三目运算符做,卡了本蒟蒻好久,最终子啊大佬同学的帮助下做出来了
创建了一个一维数组,循环输入判断是否大于0,如果大于就输出
A482.找到大于0的数
何必定义多个变量或数组,一个就行 代码(不想得用循环了):
代码
#include<bits/stdc++.h> using namespace std; int main(){ int a,b,c; cin>>a>>b>>c; if(a>0){ cout<<a<<endl; } if(b>0){ cout<<b<<endl; } if(c>0){ cout<<c<<endl; } return 0; }
#include<bits/stdc++.h>//submitRecord// using namespace std; //const int N=1e7+10; int main(){ //freopen("","r",stdin); //freopen("","w",stdout); ios::sync_with_stdio(); cin.tie(nullptr); cout.tie(nullptr); int n[4]; for(int i=1;i<=3;i++){ cin>>n[i]; if(n[i] >0 ) cout<<n[i]<<endl; } //fclose(stdin); //fclose(stdout); return 0; }
提交答案之后,这里将显示提交结果~