好的,该程序在使用循环时似乎很容易,但是 if else if 和 else 是否可以在我尝试过的这些条件下做到这一点,这是我的努力,但我失败了,完全失败了。
#include<iostream>
#include<conio.h>
int main(){
using namespace std;
int a,b,c,d,e,f,g,h,j,k,l;
int c1=0;
int c2=0;
int c3=0;
int c4=0;
cout<<"please enter first number\n";
cin>>a;
cout<<"please enter second number\n";
cin>>b;
cout<<"please enter third number\n";
cin>>c;
cout<<"please enter fourth number\n";
cin>>d;
cout<<"please enter fifth number\n";
cin>>e;
cout<<"please enter sixth number\n";
cin>>f;
cout<<"please enter seventh number\n";
cin>>g;
cout<<"please enter eighth number\n";
cin>>h;
cout<<"please enter ninth number\n";
cin>>j;
cout<<"please enter tenth number\n";
cin>>k;
cout<<"please enter eleventh number\n";
cin>>l;
if(a==1)
{
c1=a+1;
}
else if (a==1 && b==1)
{
c2=a+b;
}
else if (a==1 && b==1 && c==1)
{
c3=a+b+c;
}
else if (a==4)
{
c4=a+1;
}
cout<<"no of 1's="<<c1;
getch();
}
我正在取值,在取值后我想表明 1 出现了多少时间