#include<cstdlib> #include<iostream> using namespace std; int main() { int n; 2<=n<=100;

cin>>n;
for(int i=(n*n+(n-1));i>=(n*(n-1)+1);i-=2)
{cout<<i<<endl;}
system("pause");
}
怎样把输出放在一行?
急急急急!!!!
正在线,急急急!

#include<cstdlib> 
#include<iostream> 
using namespace std; 
int main() 
{
int n; //2<=n<=100;

cin>>n;
    for(int i=(n*n+(n-1));i>=(n*(n-1)+1);i-=2)
{cout<<i<<" ";} //去掉换行,加个空格
system("pause");
return 0;
}

温馨提示:内容为网友见解,仅供参考
无其他回答

#include<cstdlib> #include <iostream> using namespace std; int m...
include <cstdlib> #include <iostream> int main() { using namespace std; unsigned n; cin >> n; cout << n << endl; bool leading = true; do { int c = n % 10; if (c != 0 || !leading) { leading = false; cout << c; } ...

C语言的死循环
include <cstdlib> include <iostream> using namespace std;int main(int argc, char* argv[]){ int a, i, j, b, c, d;cout << "请输入一个奇数:" << endl;cin >> a;for (i = 0; i < (a + 1) \/ 2; i = i + 1){ for (j = (a + 1) \/ 2; j > i; j--...

c++一个小程序编写
include<cstdlib>#include<iostream>using namespace std;int main(){int n,s=1;cin>>n;for(int i=1;i<=n;i++){s*=i;}cout<<s;system("pause");return 0;}

C++程序编写 第五题!!!
include <iostream>#include <cstdlib>#include <algorithm>using namespace std;int main(){int n;cin >> n; int *arr = new int[n];for(int i=0; i<n; ++i) arr[i] = rand() % 100;for(int i=0; i<n; ++i) cout << arr[i] << " "; cout << endl;sort(arr, arr...

c++中如何定义字符型变量
include <iostream> include <cstdlib> using namespace std;int main (){ char a,b;int c,d;cin>>a>>b; \/\/应该是先输入a和b c=a-96;d=b-96; \/\/然后再答处理c和d的值。cout<<c<<'\\n'<<d<<endl;system ("pause");return 0;} 对于C与C++来说是没有字符串型的数据类型的,...

C\/C++\/C#从数组中随机抽取一个数(要源码\/重奖)
本人在Borland C++平台已经成功运行该代码,没问题的。include<iostream> include<iomanip> include<cstdlib> include<ctime> using namespace std;int main(){ int a[10][6]={1,2,3,4,5,6,7,8,9,0,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,...

c++利用for循环完成如下图案: *** *** *** ** * ** *** *** ***...
include <iostream> include <cstdlib> using namespace std;int main(){ int n,i,j;scanf("%d",&n);for (i =1-n; i<n; i++){ for(j=0; j<=abs(i); j++)cout<<"*";cout<<endl;} return 0;}

C++随机数的生成?
你需要先初始化随机数种子 include <iostream> include <cstdlib> include <ctime> using namespace std;int main(){ srand((int)time(0)); \/\/ 产生随机种子 把0换成NULL也行 for (int i = 0; i < 10; i++){ cout << rand()%100<< " ";} return 0;} ...

用new运算符动态分配一个长度为n的整型数组
include<iostream>#include<cstdlib>using namespace std;int main() {int n;cin >> n;int *p = new int[n];for (int i = 0; i < n; i++)p[i] = rand() % 6 + 1;for (int i = 0; i < n; i++) {for (int j = i; j < n; j++)if (p[j] <= p[i])swap...

C++ 编程问题、求大神解答
return 0;} 第三题:#include<iostream> include<cstdlib> include<cmath> include<iomanip> using namespace std;int main(){ double q,sum=0;int n;cout<<"输入等比数列的公比q和项数n,用空格隔开:";cin>>q>>n;cout<<"等比数列的各项为:"<<endl;for(int i=0;i!=n;i++){cout<<...

相似回答