ctrl +z 的使用
#include<iostream> using namespace std;main() {int num,sum=0;while(cin>>num) {sum+=num;}cout<<"和为"<<sum<<endl; }
#include<iostream> using namespace std;
main()
{
int num,sum=0;
while(cin>>num)
{
sum+=num;
}
cout<<"和为"<<sum<<endl;
}
*************************************************************************************************************************************
以 0 结束
#include<iostream> using namespace std;main() {int num,sum=0;while (cin>>num,num){sum+=num;}cout<<"和为"<<sum<<endl; }
#include<iostream>
using namespace std;
main()
{
int num,sum=0;
while (cin>>num,num)
{
sum+=num;
}
cout<<"和为"<<sum<<endl;
}
**********************************************************************************************************************************************
以 # 结束
#include<iostream> using namespace std;main() {int num,sum=0;while (cin>>num && num !='#'){sum+=num;}cout<<"和为"<<sum<<endl; }
#include<iostream>
using namespace std;
main()
{
int num,sum=0;
while (cin>>num && num !='#')
{
sum+=num;
}
cout<<"和为"<<sum<<endl;
}
****************************************************************************************************************************
#include<iostream> using namespace std;main() {int n,num,sum=0;cin>>n; while(n--){cin>>num;sum+=num;}cout<<"和为"<<sum<<endl; }
#include<iostream>
using namespace std;
main() {
int n,num,sum=0;
cin>>n;
while(n--)
{
cin>>num;
sum+=num;
}
cout<<"和为"<<sum<<endl;
}
#include<iostream> using namespace std;main() {int i,n,num,sum=0;cin>>n; for (i=0;i<n;i++){cin>>num;sum+=num;}cout<<"和为"<<sum<<endl; }
#include<iostream>
using namespace std;
main()
{
int i,n,num,sum=0;
cin>>n;
for (i=0;i<n;i++)
{
cin>>num;
sum+=num;
}
cout<<"和为"<<sum<<endl;
}
*************************************************************************************************************************************************