Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  mass
Language: C/C++
Code:
#include <stdio.h>

int main(){
    float input_m,input_f1,input_f2,input_f3, s[500][12],test_1,test_2,test_3;
    int turns,id,a,p,carbon,group;

    printf("Molecular ion r.a.m.:n");
    //canf("%f",&input_m);
    input_m = 134;
    /*
    printf("fragment ion 1 r.a.m.:n");
    scanf("%f",&input_f1);
    printf("fragment ion 2 r.a.m.:n");
    scanf("%f",&input_f2);
    printf("fragment ion 3 r.a.m.:n");
    scanf("%f",&input_f3);
    */
    // /*
    if(input_m!=0 && input_f1!=0 && input_f2!=0 && input_f3!=0 ){
        p = 1;
        carbon = 6;
        while(p<=500){
            if(carbon>0){
                //setup

                s[p][0] = carbon;
                s[p][1] = s[p][0]*2;
                for(group=2;group<=12;group++){
                        s[p][group] = 2;
                }


                turns = 12;
                while(turns>=1){
                //TEST
                test_1 = 0;
                for(group=0;group<=12;group++){
                        test_1 = test_1 + s[p][group] ;
                    }

                test_3 = 12*s[p][0] + 1*s[p][1] + 16*s[p][2] + 16*s[p][3] + 35.5*s[p][4] + 79.9*s[p][5] + 15*s[p][6] + 29*s[p][7] + 17*s[p][8]+ 33*s[p][9] + 77*s[p][10];

                if (test_3 == input_m && test_1 == 2*carbon + 2){
                    id = 1;
                }else{
                    id = 0;
                }
                if(id == 0){
                    s[p][turns]--;
                } else{
                    p++;
                }
                if(s[p][turns] == 0){
                    s[p][turns] = 2;
                    turns--;
                }
                }
                test_2 = 0;
                for(group=2;group<=12;group++){
                        test_2 = test_2 + s[p][group] ;
                    }
                if(test_2 == 0){
                    carbon--;
                }




        }else{
            s[p][0] = 0;
            p = 501;

        }
        }
        p=0;
        while(p<=500){
            if(s[p][0]!= 0){
                for(a=0;a<=12;a++){
                    printf("%f",s[p][a]);
                }
                printf("n");
            } else{
                p = 501;
            }
        }
        return 0;
        } else {
            printf("Error!");
            return 0;
        }


}




    //*/

          
Comments: