C++编程。请大牛帮忙写代码!!!

作者&投稿:山怪 (若有异议请与网页底部的电邮联系)
c++程序请大牛帮忙~

// for(int i=0;i>=0;i++){// int a=s2[i];// if ((a>=65&&a=97&&a<=122)){// c=i;// i=0;// }// }代码中,判断有小写字母或者大写字母的时候,会把c=i,并把i=0,这么for循环就不能退出而陷入死循环。

double js(double a)
{
return a*a;

}
double js(double a,double b)
{
return a*b;

}
double js(double a,double b,double c)
{
return a+b+c;

}

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <conio.h>

const unsigned int g_uIDbit = 6;
const unsigned int g_uCount = 10;
const unsigned int g_uRadix = 100;

enum operatorType
{
    op_jia, op_jian, op_cheng, op_chu, op_max
};

void InputID();
bool ActionMenu();
bool VerifyID(const char* str);
bool IsDigit(char c);
bool IsChar(char c);
void EditString(char* str, int n);

int main()
{
    int x[g_uCount] = { 0 };
    int y[g_uCount] = { 0 };

    int corr[g_uCount] = { 0 };
    int user[g_uCount] = { 0 };

    char key[g_uCount] = { 0 };

    int nCorr = 0;

    srand(time(NULL));


    InputID();

    if ( !ActionMenu() )
        return 0;

    time_t begin = time(NULL);

    for (unsigned int i=0; i<g_uCount; ++i)
    {
        int op = rand()%op_max;
        
        x[i] = rand()%g_uRadix;
        y[i] = rand()%g_uRadix;

        switch ( op )
        {
        case op_jia:
            key[i] = '+';
            corr[i] = x[i]+y[i];
            break;
        case op_jian:
            key[i] = '-';
            corr[i] = x[i]-y[i];
            break;
        case op_cheng:
            key[i] = '*';
            corr[i] = x[i]*y[i];
            break;
        case op_chu:
            key[i] = '/';
            if ( 0 == y[i] )++y[i];
            corr[i] = x[i]/y[i];
            break;
        default:
            break;
        }

        printf("q%-2d: %d %c %d = ", i+1, x[i], key[i], y[i]);
        scanf("%d", &user[i]);
    }

    system("cls");

    printf("
Result Information:

");
    printf("QuestionsCorrect AnswerYour Answer
");
    printf("
--------------------------------------------
");
    for (unsigned int i=0; i<g_uCount; ++i)
    {
        printf("q%-2d: %d %c %d %d%d
", i+1, x[i], key[i], y[i], corr[i], user[i]);
        if ( corr[i] == user[i] )
            ++nCorr;
    }

    printf("
--------------------------------------------
");
    printf("rigth: %d, error: %d, time: %ds

", nCorr, g_uCount-nCorr, time(NULL)-begin);

    return 0;
}

void InputID()
{
    for ( ; ; )
    {
        char id[g_uIDbit];
        printf("Please input your ID :");
        EditString(id, g_uIDbit);

        if ( VerifyID(id) )
        {
            printf("Login Success!

");
            break;
        }
        else
        {
            printf("You Input ID is invalid! Please reenter.

");
        }
    }
}

bool ActionMenu()
{
    printf("1:start test
2:exit
Please input 1 or 2:");

    for ( ; ; )
    {
        char key = getch();
        if ( '1' == key )
        {
            printf("%c
Test already start ...

", key);
            return true;
        }

        if ( '2' == key )
        {
            printf("%c
bye bye!
", key);
            return false;
        }
    }
}

bool VerifyID(const char* str)
{
    for (unsigned int i=0; i<g_uIDbit; ++i)
    {
        if ( i<2 )
        {
            if ( !IsChar(str[i]) ) return false;
        }
        else
        {
            if ( !IsDigit(str[i]) ) return false;
        }
    }

    return true;
}

bool IsChar(char c)
{
    return (c>='A'&&c<='Z' || c>='a'&&c<='z');
}

bool IsDigit(char c)
{
    return (c>='0'&&c<='9');
}

void EditString( char* str, int n)
{
    int  i = 0;
    char c = 0;

    for (c = getch(); '' != c; c = getch())
    {
        if ('\b' == c)
        {
            if (i > 0)
            {
                str[--i] = 0;
                printf("\b \b");
            }
        } 
        else
        {
            if (i < n)
            {
                str[i++] = c;
                printf("%c", c);
            }
        }
    }

    printf("
");
}


不懂再问我



没什么难度。相信我吧。学过C语言的都会!因C++的侧重点放在了类和对象上,所以只学C++的话,不一定会做。

我有空可以玩玩,你要等等哦


【200分在线等】求大牛帮【JAVA编程】,新手数列问题,谢谢!
按照你的要求编写的Java程序如下:import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.File;import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;public class HH { public static void main(String[] args) throws IOException { File rf=new Fil...

作文 编程让我陶醉
我们老师要求我写“———让我陶醉”的作文,我选编程,那个有一点编程知识的大牛帮我想一下该如何写??如果我觉得好的话,还可以再加分越快越好最好在明天之前... 我们老师要求我写“———让我陶醉”的作文,我选编程,那个有一点编程知识的大牛帮我想一下该如何写??如果我觉得好的话,还可以再加分越快越好最好...

推荐几个可以赚钱的APP
1、米赚:米赚是一个手机赚钱的应用,让用户在玩手机的同时还能赚到钱,支持Android系统和Apple苹果越狱系统。用户可以使用米赚安装系统推荐的优秀应用,评论和分享应用,完成指定任务等方式赚取大米,还可以把大米变现成充值卡、Q币、支付宝充值及点卡等。米赚通过手机端做任务,米赚是一款让你在玩手机的同时...

有打字赚钱的软件么
打字就能赚钱的软件有:1、超速打字:是一款非常稳定的打字软件,深受广大用户的喜爱,在软件上面记录的积分折算成换成现金,许多用户在晚上工作还能额外获得更多丰厚的奖励。2、阳光打字:作为一款活动超多打字难度最低的软件,赚钱多多也就是必然的了,每天看打字高手在上面冲击排名,发扬敌不睡我不睡的死...

西市区15261712457: 求一高手编写个c++的程序,本人一窍不通.还望各位帮忙. -
歧雪清芬: #include "stdio.h" float fun(float a[],int n,float *max,float *min) { float s=0; for(int i=0;i<n;i++) { if(*max<a[i]) *max=a[i]; if(*min>a[i]) *min=a[i]; s=s+a[i]; } return (s-*max-*min)/(n-2); } int main() { float a[100],max,min; int i,n; printf("输入个数:"); ...

西市区15261712457: C++编程,求大神帮忙 -
歧雪清芬: #include<iostream> #include<cmath> using namespace std; int pdxz(int, int, int); void qmj(int, int, int); int main() { int x, y, z; cin >> x >> y >> z; int m = pdxz(x, y, z); if(m) //m等于1时执行 qmj(z, y, z); cin.get(); cin.get(); return 0; } int pdxz(int x, int y, int z) ...

西市区15261712457: 急求高手帮忙做一个c++编程
歧雪清芬: 一: #include <iostream> using namespace std; int main() { for(int i=0;i<5;++i) { for(int a=0;a<i;++a) { cout<<" "; } for(int j=i;j<5;++j) { cout<<"*"; } cout<<endl; } return 0; } 二: #include <iostream> using namespace std; int main() { for(int i=0;i<...

西市区15261712457: 求高手帮忙编写一下C++程序
歧雪清芬: #incude"iostream.h" void main() { int a,b,c,d,xx[4],temp; cout<<"请输入四个整数"<<endl; for(int i=0;i<=3;i++) { cin>>xx[i];} for(int j=0;j<=3;j++) for(int k=j+1;k<=3;k++) { if(xx[j]<x[k]) { temp=xx[j]; xx[j]=xx[k]; xx[k]=temp; } } for(i=0;i<=3;i++) { cout<<xx[i]<<endl; } }4个整数分别为a、b、c、d

西市区15261712457: 急!!!一个关于c++编程的问题,需要大家帮我写一个程序,在线等,高手帮忙啊 -
歧雪清芬: 代码送上:#include<iostream> using namespace std; long Fibonacci(long num) { if (num == 0) return 0; else if (num == 1) return 1; else return Fibonacci(num-2) + Fibonacci(num-1); } void main() {long num; cout << "Enter a number:"; cin >> num; cout << "Fibonacci(" << num << "):" << Fibonacci(num) << endl; }

西市区15261712457: 请大佬帮忙写个c++程序! -
歧雪清芬: #include <stdio.h> int main() { int n, i, j; scanf("%d", &n); for(i = 1;i <= n;i++) {for(j = 1;j <= i;j++) printf("%d*%d=%2d\t", j, i, i*j); printf("\n"); } }

西市区15261712457: 请帮我编写一个c++程序,本人c++新手,不要编的太难我看不懂,谢谢了. -
歧雪清芬: #include void scramble(char *src, char *dst) { int i = 0; for(i = 0; src[i]!= 0; i++) dst[i] = src[i] + i + 1; } void descramble(char *src, char *dst) { int i = 0; for(i = 0; src[i]!= 0; i++) dst[i] = src[i] - i - 1; } int main() { char s[100], s1[100]; cin >> s; coutscramble(s, s1); coutdescramble(s1, s); cout }

西市区15261712457: 本人初学c++,自己写的一段求平方根的代码,有点问题,请大牛指点.
歧雪清芬: 需要手动设置输出小数位数,在输出语句前加入以下设置语句: cout.precision(14);或cout&lt;&lt;setprecision(8);(此时用到头文件#include &lt;iomanip&gt;) 另外,二分法采用以下程序更简洁, #include &lt;iostream&gt; #include &lt;cmath&...

西市区15261712457: 请帮我编写一段C++程序的代码? -
歧雪清芬: #include using namespace std; void read(int x,int *sp) //读入数组 { for (x--;x>=0;x--) cin>>sp[x]; } void print(int x,int *sp) //打印数组 { for(x--;x>=0;x--) cout cout} void swap(int &a, int &b) { int t; t = a; a = b; b = t; } void sort(int x,int *sp) { //冒泡 for(int i=0;...

西市区15261712457: 请帮忙写一个C++程序 -
歧雪清芬: #include <stdio.h> void main() {int x, y, z;for(x = 1; x <= 20; x++)for(y = 1; y <= 20; y++)for(z = 1; z <=20; z++){if((x + y + z == 20) && (5 * x + 4 * y + 2 * z) == 50)printf("公猴:%d,母猴:%d,小猴:%d",x,y,z);}getchar(); }

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网