实际上,我正在创建一个 Angular 应用程序,并且在工作时遇到了这些错误:
npm ERR! Unexpected end of JSON input while parsing near '...,"karma-qunit":"*","k'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Yuvan\AppData\Roaming\npm-cache\_logs\2018-12-02T14_06_06_337Z-debug.log
Package install failed, see above.
Run Code Online (Sandbox Code Playgroud) 好吧,所以程序的目的是绘制和椭圆形并在屏幕上移动它.代码在Eclipse上编译时没有错误,但是在运行时,不会在屏幕上绘制或移动椭圆.我一直在研究,似乎线程必须做很多事情,但是我需要一个这个简单的程序吗?我很明显是使用Swing进行GUI编程的新手,所以我很感激解释或链接到一个关于线程或相关概念的程序的任何添加.
public class Game extends JPanel
{
int x =0;
int y =0;
private void moveBall()
{
x+=1;
y+=1;
}
public void paint (Graphics g)
{
super.paint(g);
g.fillOval(x, y, 30, 30);
}
public static void main(String[] args) {
JFrame frame = new JFrame("Animation");
Game game = new Game();
frame.add(game);
frame.setVisible(true);
frame.setSize(300,400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
while (true)
{
game.moveBall();
game.repaint();
}
}
}
Run Code Online (Sandbox Code Playgroud) 您能否解释为什么以下程序的结果不同?
计划:
#define MUL(X) X*X
int main()
{
int i=3;
cout<<MUL(++i)<<"\n";
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:
25
Run Code Online (Sandbox Code Playgroud) 为什么for这只运行5次?因为它得到 5 个字符然后停止。如果我更改i<10为i<5它只运行 3 次。
#include <stdio.h>
char a[1000];
int main()
{
char a[100];
for(int i=0;i<10;i++)
{
scanf("%c",&a[i]);
}
}
Run Code Online (Sandbox Code Playgroud) 为什么要显示笑脸而不是用户名?
更改控制台属性没有帮助...
#include "pch.h"
#include <windows.h>
#include <Lmcons.h>
#include <string>
#include <iostream>
std::string UserName() {
TCHAR username[UNLEN + 1];
DWORD size = UNLEN + 1;
std::string UserName1;
UserName1 = GetUserName((TCHAR*)username, &size);
std::cout << UserName1 << std::endl;
return UserName1;
}
int main()
{
UserName();
}
Run Code Online (Sandbox Code Playgroud)
结论:☺
我想要的是获取目录中存在的所有文件,然后向该文件添加 .enc 扩展名。示例-让 File.txt 存在然后我将执行一些与加密相关的任务,之后新文件名将是 File.txt.enc
这是我的代码:
#include <dirent.h>
#include <stdio.h>
#include <string.h>
int main(void)
{
DIR *d;
struct dirent *dir;
char *name;
int val;
d = opendir(".");
if (d)
{
while ((dir = readdir(d)) != NULL)
{
name=dir->d_name;
printf("File Found:%s\n",name);
strcat(name,".enc");
val=rename(dir->d_name,name);
if(val==0)
printf("Encrypted File:%s\n",name);
else
perror("Error: ");
}
closedir(d);
}
return(0);
}
Run Code Online (Sandbox Code Playgroud)
但我得到这样的输出......
File Found:write_pgm_img.c
Error: : No such file or directory
File Found:realloc.c
Error: : No such file or directory
File Found:getusage.txt
Error: : No such file …Run Code Online (Sandbox Code Playgroud) C++:
#include <iostream>
using namespace std;
void factorial(int a){
int f = 1;
for(int i = 1;i<=a; i++){f*=i;};
cout << f << endl;
}
int main()
{
factorial(number);
}
Run Code Online (Sandbox Code Playgroud)
Python:
def factorial(a):
f=1
for i in range(1,a+1):
f*=i
return f
n=str(factorial(num))
print(n+"\n\n\n")
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?15 岁后我无法从 C++ 中获取正常答案!在 python 中,这适用于 17000!如果问题很愚蠢,我很抱歉。我今天才开始使用 C++
我正在通读《C for Dummies》,但在解读某些内容时遇到了困难。
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define FALSE 0
#define TRUE !FALSE
#define OMEGA ('Z' - 'A')
int main() {
int done;
long int r;
char alpha;
srandom((unsigned)time(NULL));
done = FALSE;
while(!done) {
r = random() % OMEGA; // basically, OMEGA = 25
alpha = 'A' + (char)r;
if (alpha =='Q') done = TRUE;
putchar(alpha);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我知道 #define OMEGA ('Z' - 'A') 将常数限制为 0 - 25。如果这是错误的,请纠正我。我遇到的问题是 alpha = 'A' + (char)r; 为什么“A”不是 65(就 ASCII …
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int userAgeYears = 0;
int userAgeDays = 0;
int userWeight = 0;
int userHeight = 0;
int BMI;
printf("Enter your age in years: \n");
scanf("%d", &userAgeYears);
userAgeDays = userAgeYears * 365;
printf("Enter your weight in pounds: \n");
scanf("%d", &userWeight);
printf("Enter your height in inches: \n");
scanf("%d", &userHeight);
BMI = ((userWeight/(userHeight * userHeight)) * 703);
printf("You are %d days old.\n", userAgeDays);
printf("Your BMI is: %d\n", BMI);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
//我的BMI结果使计算保持为0.
我做错了什么.