好吧,我是C的菜鸟,但我认为代码是基本的,直截了当的.该程序适用于大学作业,并且应该具有'isdigit()'功能.这是代码
//by Nyxm
#include <stdio.h>
#include <ctype.h>
main()
{
char userChar;
int userNum, randNum;
srand(clock());
printf("\nThis program will generate a random number between 0 and 9 for a user to guess.\n");
/*I changed it from '1 to 10' to '0 to 9' to be able to use the isdigit() function which
will only let me use a 1 digit character for an argument*/
printf("Please enter a digit from 0 to 9 as your guess: ");
scanf("%c", userChar);
if (isdigit(userChar))
{ …Run Code Online (Sandbox Code Playgroud) 我希望能够Press any key to exit在程序完成时做一些事情,但却无法弄清楚如何.
当我运行程序时,终端退出后才能看到结果.
//by Nyxm
#include <stdio.h>
main() {
int temp, x, flag, num, size;
printf("\nEnter how many numbers you wish to enter: ");
scanf("%d", &size);
int array[size];
for (x = 0; x < size; x++) {
printf("Enter an integer: ");
scanf("%d", &num);
array[x] = num;
}
printf("Please enter either 1 or 2\n1:\tAscending\n2:\tDescending\n\n...");
scanf("%d", &num);
if (num == 1) {
flag = 0;
while (flag == 0) {
flag = 1;
for (x = 1; …Run Code Online (Sandbox Code Playgroud) 我继续在我尝试为销售变量分配值的每一个案例中获得FormatException.谁知道我做错了什么?我应该把这个控制台程序作为学习循环的作业,但我发现更多关于其他事情.它应该按照每次销售的10%佣金保持销售人员佣金的运行标签.无论如何,这里是代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TubSales
{
class Program
{
static void Main(string[] args)
{
char initial;
const double COMM_INT = 0.10;
double sale, aComm = 0, bComm = 0, eComm = 0;
Console.Write("Enter 'A' for Andrea, 'B' for Brittany,\n'E' for Eric, or 'Z' to quit >> ");
initial = Convert.ToChar(Console.Read());
while (initial != 'z' && initial != 'Z')
{
switch (initial)
{
case 'a':
case 'A':
Console.Write("Enter the sales for Andrea >> ");
sale …Run Code Online (Sandbox Code Playgroud)