问题标题: 酷町堂:自定义算法<0.5>

0
1
已解决
许金夫
许金夫
初级天翼
初级天翼

震惊!时隔41天<自定义算法>又更新了!

本次更的是矩阵

//不要说我更矩阵水,我会的高级算法早就更完了......

上代码!

-----

-----

-----

-----

-----

-----

-----

-----

-----

-----

#include <bits/stdc++.h>
#include<windows.h>
using namespace std;
#define DIGIT   4  
#define DEPTH   10000  
#define MAX     30000  
/*
for(int i=0;i<spn.size();i++){
        cout<<spn[i];
        Sleep(50);
    }
*/
string p1="好消息,好消息!<自定义计算>更新了!!!";
string p2="<自定义计算2.0>将会有以下更新:";
string p3="[1]:1.0系统中复杂的if将由函数代替";
string p4="[2]:2.0更新将出现多种算法!!!";
string p5="[3]:吐槽一下,希望这次不要再有人盗版我的代码了~";
string p6="好了,话不多说,看一看这次<自定义计算>全家桶将加入那些算法吧~"; 
string ss1="||            ————请选择项目————                               ||";
string ss2="||                 [1]<高精度>                                         ||";
string ss3="||                 [2]<递推>                                           ||";
string ss4="||                 [3]<递归>                                           ||"; 
string ss5="||                 [4]<模拟>                                           ||";
string ss6="||                 [5]<埃氏筛>                                         ||"; 
string ss7="||                 [6]<数组>                                           ||"; 



string ss1_1="||                 [1]<高精度>x+y                                      ||";
string ss1_2="||                 [2]<高精度>x-y                                      ||";
string ss1_3="||                 [3]<高精度>x*y                                      ||";
string ss1_4="||                 [4]<高精度>x/y                                      ||";
string ss2_1="||                 [1]<递推>杨辉三角                                   ||";
string ss2_2="||                 [2]<递推>斐波那契                                   ||";
string ss2_3="||                 [3]<递推>位数问题                                   ||";
string ss3_1="||                 [1]<递归>八皇后                                     ||";
string ss3_2="||                 [2]<递归>汉诺塔                                     ||"; 
string ss3_3="||                 [3]<递归>排列组合                                   ||"; 
string ss3_4="||                 [4]<递归>素数环                                     ||";
string ss4_1="||                 [1]<模拟>多项式输出                                 ||"; 
string ss4_2="||                 [2]<模拟>补码                                       ||"; 
string ss4_3="||                 [3]<模拟>进制转换                                   ||";
string ss4_4="||                 [4]<模拟>有序数组合并                               ||"; 
string ss4_5="||                 [5]<模拟>滑动窗口                                   ||";
string ss5_1="||                 [1]<埃氏筛>分解质因数                               ||";
string ss5_2="||                 [2]<埃氏筛>质因数个数                               ||"; 
string ss5_3="||                 [3]<埃氏筛>找出质因数                               ||"; 
string ss6_1="||                 [1]<数组>二维数组循环次数                           ||"; 
string ss6_2="||                 [2]<数组>矩阵转置并求和                             ||";













string sp1="有一个多项式:f(x)=a[n]*(x^n)+a[n-1]*(x^(n-1))+...+a[1]*x+a[0],其中a[n]!=0.你需要输入n和a[n],即可得出f(x)";
string sp2="八皇后问题--------一个古老而著名的问题,是回溯算法的典型案例。";
string sp3="下面将会输出所有八皇后的选项<此题在题库里无法AC>,所有的'#'代表皇后,为了方便观看,每次输出后将会稍加暂停,请耐心等待~";
string sp4="现在输入两个从小大到排列的有序数组,长度分别为m、n,就可以将这两个有序数组合并为一个长度为m+n的有序数组。";
string sp5="现在有一个长为m的数组A,给定一个整数n(n<m),请你输入所有的数值,查找A中有多少个长度为n的子数组的和为k。";
string sp6="此函数可以计算出在所有的n位数中,有多少个数字中有偶数个数字k";
string sp7="输入n,输出自然数1到n所有不重复的排列";
string sp8="输入n,组成一个环,在这个环中任意两个相邻的数字的和都是素数";
string sp9="输入合数n,把n分解成若干质因数乘积的形式"; 
string sp10="输入n,求出n的所有不重复的质因数个数";
string sp11="输入n,找出它的所有质因数(重复的只取一个)";






static int gEightQueen[8] = { 0 }, gCount = 0;//八皇后的定义 
typedef int bignum_t[MAX+1];//高精度除法的定义 


void shuxue(){
    int x[5000000];
    memset(x,0,sizeof(x));
    cout<<"输入一组数据,系统将对他进行分析"<<endl;
    int n;
    cout<<"这组数据的个数:";
    cin>>n;
    int zuju;
    cout<<"组距的值为(不要告诉我你不知道组距是啥):";
    cin>>zuju; 
    for(int i=1;i<=n;i++){
        cin>>x[i];
    } 
    cout<<endl;
    sort(x+1,x+n+1);
    int big=x[n];
    int small=x[0];
    int zushu=(big-small)/zuju+1;
    cout<<"这组数据的分组组数为"<<zushu<<"个"; 
}


void print()//八皇后
{
    cout<<"第"<<gCount<<"个八皇后排列-----------------------------------"<<endl;
    cout<<"                            =========="<<endl;
    for (int i = 0; i < 8; i++)
    {    
        cout<<"                            |"; 
        int inner;
        for (inner = 0; inner < gEightQueen[i]; inner++)
            cout << " ";
            cout <<"#";
        for (inner = gEightQueen[i] + 1; inner < 8; inner++)
            cout << " ";
        cout<<"|"; 
        cout << endl;
    }
    cout<<"                            =========="<<endl;
    Sleep(200);
}
int check_pos_valid(int loop, int value){//八皇后
    int index;
    int data;
    for (index = 0; index < loop; index++)
    {
        data = gEightQueen[index];
        if (value == data)
            return 0;
        if ((index + data) == (loop + value))
            return 0;
        if ((index - data) == (loop - value))
            return 0;
    }
    return 1;
}
void eight_queen(int index)//八皇后 
{
    int loop;
    for (loop = 0; loop < 8; loop++)
    {
        if (check_pos_valid(index, loop))
        {
            gEightQueen[index] = loop;
            if (7 == index)
            {
                gCount++, print();
                gEightQueen[index] = 0;
                return;
            }
            eight_queen(index + 1);
            gEightQueen[index] = 0;
        }
    }
}
void dg1(){//八皇后主函数
    for(int i=0;i<sp2.size();i++){
        cout<<sp2[i];
        Sleep(50);
    }
    cout<<endl;
    for(int i=0;i<sp3.size();i++){
        cout<<sp3[i];
        Sleep(50);
    }
    cout<<endl;
    Sleep(100);
    eight_queen(0);
    cout << "总数为=" << gCount << endl;
}  
int cc;//汉诺塔
void Move(int n, char a, char b){//汉诺塔
    printf("第%d次移动 Move %d: Move from %c to %c !\n",++cc,n,a,b);
    Sleep(100); 
}
void Hanoi(int n, char a, char b, char c)//汉诺塔
{
    if (n == 1)
    {
        Move(n, a, c);
    }
    else
    {
        Hanoi(n - 1, a, c, b);
        Move(n, a, c);
        Hanoi(n - 1, b, a, c);
    }
}
void dg2(){//汉诺塔主函数 
    int n=8;
    printf("汉诺塔的层数:\n");
    scanf(" %d",&n);
    Hanoi(n, 'A', 'B', 'C');
} 
int used[10];
int pl[10];
int n,cnt=0;
void dfs1(int t){
    if(t>n){
        for(int i=1;i<=n;i++){
            cout<<pl[i]<<" ";
        }
        cout<<endl;
        return ;
    }
    for(int i=1;i<=n;i++){
        if(used[i]==0){
            pl[t]=i;
            used[i]=1;
            dfs1(t+1);
            used[i]=0;
        }
    }
}
void dg3(){
    for(int i=0;i<sp7.size();i++){
        cout<<sp7[i];
        Sleep(50);
    }
    cout<<endl<<"n的数值=";
    cin>>n;
    dfs1(1); 
}

int n1, used1[25], a1[25], cnt1;
bool isprime(int x, int y) {
    int s = x + y;
    if(s==0) return false;
    for(int i=2; i<=sqrt(s); i++) {
        if(s%i==0) return false;
    }
    return true;
}
void dfs(int t) {
    if(t==n1+1) {
        if(isprime(a1[1], a1[t-1])) {
            cnt1 ++;
            for(int i=1; i<=n1; i++) {
                cout << a1[i] << ' ';
            }
            cout << endl;
        }
        return ;
    }
    for(int i=1; i<=n1; i++) {
        if(used1[i]==0 && (isprime(a1[t-1], i) || t==1)) {
            a1[t] = i;
            used1[i] = 1;
            dfs(t+1);
            used1[i] = 0;
        }
    }
}
void dg4() {
    for(int i=0;i<sp8.size();i++){
        cout<<sp8[i];
        Sleep(50);
    }
    cout<<endl<<"数值n=";
    cin >> n1;
    dfs(1);
    cout <<"总方案数="<< cnt1;
}


void gj1(){//高精度加法
    int a[100005];
    int b[100005];
    int c[100005];
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    memset(c,0,sizeof(c));
    string s1,s2;
    cout<<"加数x:";
    cin>>s1;
    cout<<"加数y:";
    cin>>s2;
    a[0]=s1.size();
    b[0]=s2.size();
    for(int i=1;i<=s1.size();i++)a[i]=int(s1[a[0]-i]-'0');
    for(int i=1;i<=s2.size();i++)b[i]=int(s2[b[0]-i]-'0');
    c[0]=max(a[0],b[0]);
    int jw=0;
    for(int i=1;i<=c[0];i++){
        c[i]=a[i]+b[i]+jw;
        jw=c[i]/10;
        c[i]%=10;
    }
    if(jw==1){
        c[0]++;
        c[c[0]]=jw;
    }
    cout<<"x+y=";
    for(int i=c[0];i>=1;i--){
        cout<<c[i];
    }
} 
void gj2(){//高精度减法 
    string sd,se,sa;  
    int a[100001]={0},b[100001]={0},c[100001]={0},mc,me,mz,n,mo=0; 
    cout<<"减数x:"; 
    cin>>sd;  
    cout<<"减数y:";
    cin>>se; 
    mc=sd.size();  
    me=se.size();  
    if(mc<me||mc==me&&sd<se){sa=sd;sd=se;se=sa;n=mc;mc=me;me=n;mo=-1;}   
    for(int i=1;i<=mc;i++) a[i]=sd[mc-i]-'0';  
    for(int i=1;i<=me;i++) b[i]=se[me-i]-'0';  
    int i=1,o=0;  
    while(i<=mc||i<=me)  
    {  
        if(a[i]<b[i]){a[i+1]--;a[i]+=10;}  
        c[i]=a[i]-b[i];  
        i++;  
    }  
    mz=i;while(c[mz]==0&&mz>1)mz--; 
    cout<<"x-y="; 
    if(mo==-1) cout<<"-";  
    for(int i=mz;i>=1;i--) cout<<c[i];  
}
void gj3(){//高精度乘法 
    string sa="",sb="",st="";
    int la=0,lb=0,lc=0,tla=0,tlb=0,t=0;
    bool isuselesszero=true;
    vector <int> a,b,c;
    cout<<"乘数x:";
    cin>>sa;
    cout<<"乘数y:";
    cin>>sb;
    if(sa[0]=='0' || sb[0]=='0') {
        cout<<0; 
        return ;
    }
    la=sa.length(); lb=sb.length();
    if(la>lb){
        swap(sa,sb); 
        la=sa.length(); 
        lb=sb.length();
    }
    lc=max(la,lb); 
    tla=la; 
    tlb=lb;
    reverse(sa.begin(),sa.end()); 
    reverse(sb.begin(),sb.end());
    while(tla<lc){
        sa+='0'; 
        tla=sa.length();
    }
    while(tlb<lc){
        sb+='0'; 
        tlb=sb.length();
    }
    for(int i=0;i<1000000;i++) c.push_back(0);
    for(int i=0;i<lc;i++){
        a.push_back((sa[i]-'0')); 
        b.push_back((sb[i]-'0'));
    }
    for(int i=0;i<lb;i++){
        for(int j=0;j<la;j++){
            c[i+j]+=a[j]*b[i];
            if(c[i+j]>=10){
                c[i+j+1]+=c[i+j]/10;
                c[i+j]%=10;
            }
        }
    }
    reverse(c.begin(),c.end());
    cout<<"x*y=";
    for(int i=0;i<1000000;i++){
        if(isuselesszero&&c[i]==0) continue;
        if(c[i]!=0) isuselesszero=false;
        if(c[i]<10) cout<<c[i];
        else{
            c[i-1]=c[i]/10;
            c[i]%=10;
            cout<<c[i];
        }
    }
    return ;
}







int read(bignum_t a,istream& is=cin){  //高精度除法
    char buf[MAX*DIGIT+1],ch;  
    int i,j;  
    memset((void*)a,0,sizeof(bignum_t));  
    if (!(is>>buf))   return 0;  
    for (a[0]=strlen(buf),i=a[0]/2-1;i>=0;i--)  
        ch=buf[i],buf[i]=buf[a[0]-1-i],buf[a[0]-1-i]=ch;  
    for (a[0]=(a[0]+DIGIT-1)/DIGIT,j=strlen(buf);j<a[0]*DIGIT;buf[j++]='0');  
    for (i=1;i<=a[0];i++)  
        for (a[i]=0,j=0;j<DIGIT;j++)  
            a[i]=a[i]*10+buf[i*DIGIT-1-j]-'0';  
    for (;!a[a[0]]&&a[0]>1;a[0]--);  
    return 1;  
}  
void write(const bignum_t a,ostream& os=cout){  //高精度除法
    int i,j;  
    for (os<<a[i=a[0]],i--;i;i--)  
        for (j=DEPTH/10;j;j/=10)  
            os<<a[i]/j%10;  
}  
void sub(bignum_t a,const bignum_t b,const int c,const int d){  //高精度除法
    int i,O=b[0]+d;  
    for (i=1+d;i<=O;i++)  
        if ((a[i]-=b[i-d]*c)<0)  
            a[i+1]+=(a[i]-DEPTH+1)/DEPTH,a[i]-=(a[i]-DEPTH+1)/DEPTH*DEPTH;  
    for (;a[i]<0;a[i+1]+=(a[i]-DEPTH+1)/DEPTH,a[i]-=(a[i]-DEPTH+1)/DEPTH*DEPTH,i++);  
    for (;!a[a[0]]&&a[0]>1;a[0]--);  
}  
int comp(const bignum_t a,const int c,const int d,const bignum_t b){  //高精度除法
    int i,t=0,O=-DEPTH*2;  
    if (b[0]-a[0]<d&&c)  
        return 1;  
    for (i=b[0];i>d;i--){  
        t=t*DEPTH+a[i-d]*c-b[i];  
        if (t>0) return 1;  
        if (t<O) return 0;  
    }  
    for (i=d;i;i--){  
        t=t*DEPTH-b[i];  
        if (t>0) return 1;  
        if (t<O) return 0;  
    }  
    return t>0;  
}  

void div(bignum_t c,bignum_t a,const bignum_t b){//高精度除法  
    int h,l,m,i;  
    memset((void*)c,0,sizeof(bignum_t));  
    c[0]=(b[0]<a[0]+1)?(a[0]-b[0]+2):1;  
    for (i=c[0];i;sub(a,b,c[i]=m,i-1),i--)  
        for (h=DEPTH-1,l=0,m=(h+l+1)>>1;h>l;m=(h+l+1)>>1)  
            if (comp(b,m,i-1,a)) h=m-1;  
            else l=m;  
    for (;!c[c[0]]&&c[0]>1;c[0]--);  
    c[0]=c[0]>1?c[0]:1;  
}  
void gj4(){
    bignum_t a,b,c;
    cout<<"被除数a为:";  
    read(a);  
    cout<<"除数b为:";
    read(b);  
    div(c,a,b);  
    cout<<"a/b=";
    write(c);  
    cout<<endl;  
    cout<<"a%b=";
    write(a);  
    cout<<endl; 
} 






void dt1(){//杨辉三角
    cout<<"三角的层数:";
    int n;
    cin>>n; 
    const int m = 2 * n-1;
    int arr[n + 1][m] = { 0 };
    for (int i = 0; i < n; i++)
    {
        arr[i][n - i- 1] = 1;
        arr[i][n + i -1] = 1;
    }
    for (int i = 2; i < n; i++)
    {
        for (int j = n - i + 1; j < n-2+i; j = j + 2)
            arr[i][j] = arr[i - 1][j - 1] + arr[i - 1][j + 1];
    }
    int p;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n - i - 1; j++)
            cout << "    ";
        p = 1;
        for (int j = n - i - 1; p < i + 2; j = j + 2)
        {
            cout << setw(4) << arr[i][j] << "    ";
            p = p + 1;
        }
        cout << endl;
    }
} 
void dt2(){//斐波那契数列 
    int a[10000],b[10000]; 
    string s1="1",s2="1"; 
    char x[1200];
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    int s,n,sum;
    cout<<"你求的是第几个数列:";
    cin>>n;
    for(int j=2;j<n;j++) { 
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        a[0]=s1.size(); 
        b[0]=s2.size(); 
        for(int i=1;i<=a[0];i++){ 
            a[i]=s1[a[0]-i]-'0';
        } 
        for(int i=1;i<=b[0];i++){ 
            b[i]=s2[b[0]-i]-'0';
        }
        sum=max(a[0],b[0]);
        for(int i=1;i<=sum;i++){ 
            a[i]+=b[i]; 
            a[i+1]+=a[i]/10; 
            a[i]%=10;} 
        sum++; 
        while(!(a[sum])&&(sum>1))sum--;
        s=0;
        for(int i=sum;i>=1;i--)x[s++]=a[i]+'0'; 
        s1=s2; 
        s2=x; 
    } 
    cout<<s2;
}
void dt3(){
    int j[100005];
    int o[100005];
    memset(j,0,sizeof(j));
    memset(j,0,sizeof(j));
    for(int i=0;i<sp6.size();i++){
        cout<<sp6[i];
        Sleep(50);
    } 
    cout<<endl;
    j[1]=1;
    o[1]=8;
    int n,k;
    cout<<"位数n=";
    cin>>n;
    cout<<"数字k=";
    cin>>k;
    for(int i=2;i<=n;i++){
        j[i]=j[i-1]*9+o[i-1];
        o[i]=o[i-1]*9+j[i-1];
    }
    cout<<n<<"位数中共有"<<o[n]<<"个数有偶数个"<<k;
}
void moni1(){
    int t[101];
    memset(t,-1,sizeof(t));
    for(int i=0;i<sp1.size();i++){
        cout<<sp1[i];
        Sleep(50);
    }
    int n, p;
    bool f = true;
    cout<<endl<<"n=";
    cin >> n;
    p = n;
    for(int i=1; i<=n+1; i++) {
        cout<<"t["<<i<<"]=";
        cin>>t[i];
    }
    cout<<"f(x)=";
    for(int i=1; i<=n+1; i++) {
        if(t[i]==0) {
            p --;
            continue;
        }
        if(t[i]<0) cout << "-";
        if(t[i]>0 && !f) {
            cout << "+";
        }
        if(abs(t[i])!=1 || p==0) cout << abs(t[i]);
        if(p>0) cout << "x";
        if(p>1) cout << "^" << p;
        p --;
        f = false;
    }
}
void moni2(){
    cout<<"输入一个正整数二进制:";
    string s;
    cin >> s;
    cout<<s<<"的相反数的八位二进制补码=";
    int n = 7 - s.size();
    for(int i=1; i<=n; i++) {
        s = '0' + s;
    }
    for(int i=0; i<s.size(); i++) {
        if(s[i]=='0') s[i] = '1';
        else s[i] = '0';
    }
    for(int i=s.size()-1; i>=0; i--) {
        if(s[i]=='0') {
            s[i] = '1';
            break;
        }
        s[i] = '0';
    }
    cout << 1 << s;
}
void moni3(){
    string s="0123456789ABCDEFGHIJ";
    string ans="";
    int n,k;
    cout<<"十进制数x="; 
    cin>>n;
    cout<<"k进制=";
    cin>>k;
    cout<<n<<"转化为"<<k<<"进制="; 
    while(n){
        ans=s[n%k]+ans;
        n/=k;
    }
    cout<<ans;
}
void moni4(){
    for(int i=0;i<sp4.size();i++){
        cout<<sp4[i];
        Sleep(50);
    }
    cout<<endl;
    int a[1005], b[1005], c[2005], m=0, n=0; 
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    memset(c,0,sizeof(c));
    cout<<"a数组的长度m="; 
    cin >> m ;
    cout<<"b数组的长度n=";
    cin >> n ; 
    cout<<"a数组的数值:";
    for(int i=1; i<=m; i++) {
        cin >> a[i];
    } 
    cout<<"b数组的数值:";
    for(int i=1; i<=n; i++) {
        cin >> b[i];
    } 
    cout<<"合并后的数组为:";
    int i = 1, j = 1, k = 0;
    while(i<=m && j<=n) {
        if(a[i] < b[j]) {
            c[++k] = a[i];
            i ++;
        }else {
            c[++k] = b[j];
            j ++;
        }
    }
    while(i<=m) {
        c[++k] = a[i];
        i ++;
    }
    while(j<=n) {
        c[++k] = b[j];
        j ++;
    }
    for(int i=1; i<=k; i++) {
        cout << c[i] << ' ';
    }
}
void moni5(){
    for(int i=0;i<sp5.size();i++){
        cout<<sp5[i];
        Sleep(50);
    }
    cout<<endl;
    int a[10005];
    memset(a,0,sizeof(a));
    int n, m, cnt = 0, t = 0 , k;
    cout<<"输入数组A的长度m:";
    cin >> n ;
    cout<<"输入子数组的长度n:";
    cin >> m ;
    cout<<"子数组的和k=";
    cin >> k ;
    cout<<"A数组的数值为:"; 
    for(int i=1; i<=n; i++) 
        cin >> a[i];
    for(int i=0; i<m; i++) {//初始化窗口
        t += a[i];
    }
    for(int i=m; i<=n; i++) {//模拟窗口滑动的过程
        t += a[i] - a[i-m];
        if(t == k) cnt ++;
    }
    cout << "符合的子数组的数量=";
    cout << cnt; 
}
void ass1(){
    for(int i=0;i<sp9.size();i++){
        cout<<sp9[i];
        Sleep(50);
    }
    cout<<endl<<"合数n1=";
    int n1,i=2;
    cin>>n1; 
    cout<<n1<<"=";
    do{
        while(n1%i==0){
            cout<<i;
            n1/=i;
            if(n1!=1)
                cout<<"*";  
        }
        i++; 
    }
    while(n1!=1);
}
void ass2(){
    for(int i=0;i<sp10.size();i++){
        cout<<sp10[i];
        Sleep(50);
    }
    cout<<endl;
    cout<<"正整数n=";
    long long number;
    cin>>number;
    int a ;
    for(int i=2;i<=number/2;i++){
        if(number%i==0){
            int j;
            for(j=2;j<=sqrt(i);j++){
                if(i%j==0){
                    break;
                }
            }
            if(j>sqrt(i)){
                a++;
            }
        }
    }
    cout<<number<<"的不重复质因数的个数为:"; 
    cout << a ;
}
void ass3(){
    for(int i=0;i<sp11.size();i++){
        cout<<sp11[i];
        Sleep(50);
    }
    cout<<endl;
    long long number;
    cout<<"n的值为:";
    cin>>number;
    cout<<"n的所有质因数="; 
    for(int i=2;i<=number;i++){
        if(number%i==0){
            int j;
            for(j=2;j<=sqrt(i);j++){
                if(i%j==0){
                    break;
                }
            }
            if(j>sqrt(i)){
                cout<<i<<" ";
            }
        }
    }
}

void sz1(){
    cout<<"输入二维数组的行数和列数,得到输入时循环多少次"<<endl;
    cout<<"二维数组的个数:";
    int n;
    cin>>n;
    int a,b;
    for(int i=0;i<n;i++){
        cout<<"行数:"; 
        cin>>a;
        cout<<"列数:";
        cin>>b;
        cout<<"循环次数:";
        cout<<a*b<<endl;
    }
}
void sz2(){
    cout<<"给定一个m*n的矩阵,求该矩阵的转置矩阵,再与一个n*m的矩阵求和,输出求和后的矩阵"<<endl;
    cout<<"m=";
    int n,m;
    cin>>n;
    cout<<"n=";
    cin>>m;
    cout<<"转置前的矩阵:"<<endl;
    int a[n+10][m+10],b[m+10][n+10],c[m+10][n+10];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>a[i][j];
        }
    }
    cout<<"另一个矩阵:"<<endl;
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cin>>b[i][j];
        }
    }
    cout<<"计算后的矩阵矩阵:"<<endl;
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=n;j++)
        {
            c[i][j]=a[j][i];
        }
    }
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cout<<c[i][j]+b[i][j]<<" ";
        }
        cout<<endl;
    } 
}

int main(){
    for(int i=0;i<5;i++){
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"            ";system("cls");
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"            .";system("cls");
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"            ..";system("cls");
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"            ...";system("cls");
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"            ....";system("cls");
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"            .....";system("cls");
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"            ......";system("cls");
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"            .......";system("cls");
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"            ........";system("cls");
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"            .........";system("cls");
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"             .........";system("cls");
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"              .........";system("cls");
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"               .........";system("cls");
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"                ........";system("cls");
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"                 .......";system("cls");
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"                  ......";system("cls");
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"                   .....";system("cls");
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"                    ....";system("cls");
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"                     ...";system("cls");
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"                      ..";system("cls");
        for(int i=0;i<1;i++)cout<<endl<<endl<<endl<<endl<<endl<<"                       .";system("cls");
    }
    system("cls");
    int zh,mm;//账号,密码
    cout << endl << endl << endl << endl ;
    cout<<"                     -------自定义计算 2.0-------"<<endl<<endl;
    cout<<"                 Hello~ :) 欢迎来到全新的自定义计算2.0----5/23版"<<endl; 
    cout<<"                     请输入账号:";cin>>zh;
    cout<<"                     请输入密码:";cin>>mm;
    int qw;
    bool qe=1;
    if(zh==123456&&mm==456789)qw=1;
    else qw=2;
    while(qw==2){
        if(zh!=123456)cout<<"                     账号不存在"<<endl; 
        else if(mm!=456789)cout<<"                     密码输入错误"<<endl;
        cout<<"                     请再次输入账号:";cin>>zh;
        cout<<"                     请再次输入密码:";cin>>mm;
        if(zh==123456&&mm==456789)qw=1;
        else qw=2; 
    } 
    while(qw==1){
        system("cls");
        if(qe==1){  
            for(int i=0;i<p1.size();i++){
                cout<<p1[i];
                Sleep(50);
            } 
            cout<<endl;
            for(int i=0;i<p2.size();i++){
                cout<<p2[i];
                Sleep(50);
            } 
            cout<<endl;
            for(int i=0;i<p3.size();i++){
                cout<<p3[i];
                Sleep(50); 
            } 
            cout<<endl;
            for(int i=0;i<p4.size();i++){
                cout<<p4[i];
                Sleep(50);
            } 
            cout<<endl;
            for(int i=0;i<p5.size();i++){
                cout<<p5[i];
                Sleep(50);
            } 
            cout<<endl;
            for(int i=0;i<p6.size();i++){
                cout<<p6[i];
                Sleep(50);
            } 
            cout<<endl;
            qe=0;
        }
        cout<<ss1<<endl;
        cout<<ss2<<endl;
        cout<<ss3<<endl;
        cout<<ss4<<endl; 
        cout<<ss5<<endl;
        cout<<ss6<<endl;
        cout<<ss7<<endl;
        int xuanxiang;//选项------------------------------------------------------------ 
        cout<<"请选择功能:"; 
        cin>>xuanxiang; 
        if(xuanxiang==1){//高精度 
            system("cls");
            cout<<ss1<<endl;
            cout<<ss1_1<<endl;
            cout<<ss1_2<<endl;
            cout<<ss1_3<<endl;
            cout<<ss1_4<<endl;
            int xuanxiang1;
            cout<<"你的选择:";
            cin>>xuanxiang1; 
            if(xuanxiang1==1){
                system("cls");
                gj1();
                Sleep(500);
            }
            else if(xuanxiang1==2){
                system("cls");
                gj2();
                Sleep(500);
            }
            else if(xuanxiang1==3){
                system("cls");
                gj3();
                Sleep(500);
            }
            else if(xuanxiang1==4){
                system("cls");
                gj4();
                Sleep(500);
            }
        }
        else if(xuanxiang==2){//递推 
            system("cls");
            cout<<ss1<<endl;
            cout<<ss2_1<<endl;
            cout<<ss2_2<<endl;
            cout<<ss2_3<<endl;
            int xuanxiang1;
            cout<<"你的选择:";
            cin>>xuanxiang1; 
            if(xuanxiang1==1){
                system("cls");
                dt1();
                Sleep(500);
            }
            else if(xuanxiang1==2){
                system("cls");
                dt2();
                Sleep(500);
            }
            else if(xuanxiang1==3){
                system("cls");
                dt3();
                Sleep(500);
            }
        }
        else if(xuanxiang==3){//递归 
            system("cls");
            cout<<ss1<<endl;
            cout<<ss3_1<<endl;
            cout<<ss3_2<<endl;
            cout<<ss3_3<<endl;
            cout<<ss3_4<<endl;
            int xuanxiang1;
            cout<<"你的选择:";
            cin>>xuanxiang1; 
            if(xuanxiang1==1){
                system("cls");
                dg1();
                gCount=0;
                Sleep(500);
            }
            else if(xuanxiang1==2){
                system("cls");
                dg2();
                cc=0; 
                Sleep(500);
            }
            else if(xuanxiang1==3){
                system("cls");
                dg3(); 
                Sleep(500);
                n,cnt=0;
            }
            else if(xuanxiang1==4){
                system("cls");
                dg4(); 
                Sleep(500);
                n1,cnt1=0;
            }
        }
        else if(xuanxiang==4){//模拟 
            system("cls");
            cout<<ss1<<endl;
            cout<<ss4_1<<endl;
            cout<<ss4_2<<endl;
            cout<<ss4_3<<endl;
            cout<<ss4_4<<endl;
            cout<<ss4_5<<endl;
            int xuanxiang1;
            cout<<"你的选择:";
            cin>>xuanxiang1; 
            if(xuanxiang1==1){
                system("cls");
                moni1();
                Sleep(500);
            }
            else if(xuanxiang1==2){
                system("cls");
                moni2();
                Sleep(500);
            }
            else if(xuanxiang1==3){
                system("cls");
                moni3();
                Sleep(500);
            }
            else if(xuanxiang1==4){
                system("cls");
                moni4();
                Sleep(500);
            }
            else if(xuanxiang1==5){
                system("cls");
                moni5();
                Sleep(500);
            }
        }
        else if(xuanxiang==5){//埃氏筛 
            system("cls");
            cout<<ss1<<endl;
            cout<<ss5_1<<endl;
            cout<<ss5_2<<endl;
            cout<<ss5_3<<endl;
            int xuanxiang1;
            cout<<"你的选择:";
            cin>>xuanxiang1; 
            if(xuanxiang1==1){
                system("cls");
                ass1();
                Sleep(500);
            }
            else if(xuanxiang1==2){
                system("cls");
                ass2();
                Sleep(500);
            }
            else if(xuanxiang1==3){
                system("cls");
                ass3();
                Sleep(500);
            }
        } 
        else if(xuanxiang==6){//数组 
            system("cls");
            cout<<ss1<<endl;
            cout<<ss6_1<<endl;
            cout<<ss6_2<<endl;
            int xuanxiang1;
            cout<<"你的选择:";
            cin>>xuanxiang1; 
            if(xuanxiang1==1){
                system("cls");
                sz1();
                Sleep(500);
            }
            else if(xuanxiang1==2){
                system("cls");
                sz2();
                Sleep(500);
            }
        } 
        cout<<endl;
        cout<<"是否退出?"<<endl;
        cout<<"[1]:继续"<<endl;
        cout<<"[0]:退出"<<endl;
        cout<<"你的选择:";
        cin>>qw;
    } 
    cout<<"see you next time~"<<endl;
    cout << "欢迎下次登录 "<< (char)(92) <<" ^-^ / " << endl ; 
    return 0;
} 

 


0
0
王子逸
王子逸
新手天翼
新手天翼

要是考试可以带电脑  就算屏蔽网络   我也无敌了!!! 

要是考试可以  你就发达了!!!!

0
0
徐子宸
徐子宸
中级天翼
中级天翼

666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666

0
我要回答