我正在编写将采用整数数组的代码,然后可以将其转换为所需的基数,例如base-16.
出于某种原因,终端通过该程序并打印出来
"转换数="
这是我的代码:
#include <stdio.h>
#include <cs50.h>
int convertedNumber[64];
int base;
int digit = 0;
void getNumberAndBase(void) {
int size;
printf("How many numbers to be converted??\n");
size = GetInt();
int array[size];
for (int i = 0; i < size; i++) {
printf("Number to be converted?\n");
array[i] = GetInt();
}
printf("Base?\n");
do {
base = GetInt();
if (base < 2 || base > 16) {
printf("Bad base - must be between 2 and 16. Try again!\n");
}
} while (base …Run Code Online (Sandbox Code Playgroud) 我正在编写一个程序来计算两次给定时间之间的经过时间.
由于某种原因,我收到错误:在我的main函数之前我的elapsedTime函数原型的预期标识符或'C'.
我试过在程序中移动它,如果在声明了t1和t2之后找到它,它就没有区别.有什么问题?
谢谢
#include <stdio.h>
struct time
{
int seconds;
int minutes;
int hours;
};
struct elapsedTime(struct time t1, struct time t2);
int main(void)
{
struct time t1, t2;
printf("Enter start time: \n");
printf("Enter hours, minutes and seconds respectively: ");
scanf("%d:%d:%d", &t1.hours, &t1.minutes, &t1.seconds);
printf("Enter stop time: \n");
printf("Enter hours, minutes and seconds respectively: ");
scanf("%d:%d:%d", &t2.hours, &t2.minutes, &t2.seconds);
elapsedTime(t1, t2);
printf("\nTIME DIFFERENCE: %d:%d:%d -> ", t1.hours, t1.minutes, t1.seconds);
printf("%d:%d:%d ", t2.hours, t2.minutes, t2.seconds);
printf("= %d:%d:%d\n", differ.hours, differ.minutes, differ.seconds); …Run Code Online (Sandbox Code Playgroud)