小编scr*_*you的帖子

如何在vb 2010中向数组添加元素

嘿,我得到了好消息,我很接近理解我需要做什么.我见过很多我以后可以使用的数据.但是现在我只需要或多或少地在这里获得进修课程.

我需要将元素写入数组.我知道那部分......但是在运行XML文件之前我不会知道数组的长度.所以该文件可能有1到超过9000(dbz).我知道我需要一个for循环,我只是不知道如何很好地编写for循环.

我从书中得到了一些代码,但我看不出如何编辑它.

Dim arraytester() As String
For i As Integer = 0 To arraytester.Length - 1
    'little lost here 
Next
Run Code Online (Sandbox Code Playgroud)

那么我如何绕过arraytester.Length是一个问题,如果我不知道正在使用的文件的长度.

我如何将它添加到数组中,它只是在我的书中显示输出.(或许我只是失去了它)

vb.net arrays

1
推荐指数
1
解决办法
2951
查看次数

无法让我的if语句起作用?

我知道这必须简单.但对于我的生活,我不知道为什么我不能做到这一点.

好的,所以我想从列表视图页面(得到那个)然后点击一个开关使它进入下一页(也得到了.)然后我想要一个int告诉我我在最后一页的位置(可能正在工作?)现在我无法在页面中使用If Else语句.

public class NightmareParts extends Activity
{
    public int current_AN_Number = NightmareList.AN_position_num;
    private TextView edit_title;
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.part_layout);

        // isn't working here. Why?
        // test_edit = (TextView)findViewById(R.id.directions_tv);        
        // test_edit.setText(R.string.directions_text_two);                 
        // works without this being in here. 

        setDoneButtonListener();
    }

    //Set up the Done button to initialize intent and finish
    private void setDoneButtonListener()
    {
        Button doneButton = (Button) findViewById(R.id.back_button);
        doneButton.setOnClickListener (new View.OnClickListener() {
            @Override
            public void onClick(View v)
            {
                finish();
            }
        });
    }

    private void …
Run Code Online (Sandbox Code Playgroud)

java xml android

0
推荐指数
1
解决办法
65
查看次数

为什么计数器不起作用

我想帮助一个朋友,我似乎无法得到它们.我不知道为什么但几个变量没有正确显示.

我把它撞到了我认为问题所在的地方,但我不知道如何解决它.

#include <iostream>
#include <fstream>
using namespace std;
int main() 
{
//declaring variables
ifstream myfile("input.txt");
double grades[26];
unsigned scores[8] = {0};




//getting data from text file
    for(int i=0; i<26; i++)
        {
            myfile >> grades[i];
            cin.ignore();


    if((grades[i] >= 175) && (grades[i] <= 200)) scores[7]++; 
    else if(grades[i] >= 150)                    scores[6]++;
    else if(grades[i] >= 125)                    scores[5]++;
    else if(grades[i] >= 100)                    scores[4]++;
    else if(grades[i] >= 75)                     scores[3]++;
    else if(grades[i] >= 50)                     scores[2]++;
    else if(grades[i] >= 25)                     scores[1]++;
    else if(grades[i] >= 0)                      scores[0]++;
      } …
Run Code Online (Sandbox Code Playgroud)

c++

0
推荐指数
1
解决办法
82
查看次数

为什么写入我的字符串不起作用?

以下代码无效.我在命令中收到错误cin >> h.我究竟做错了什么?

#include <iostream>
using namespace std;

int main()
{

    string h = " ";

    cout << "hi" << endl;
    cin >> h;
    cout << h << endl;
    system("pause");
    return 0;
} 
Run Code Online (Sandbox Code Playgroud)

c++ visual-c++

0
推荐指数
1
解决办法
99
查看次数

如何使用字符数组来标识字符串

对于我的类,我们使用char数组作为字符串.如果我要使用一个if else声明,如果我修改了这样的话会是这样的吗?

我知道像这样的数组会使每个字符分解成简单的字母.并使用一个if else语句,我必须像数组[1] =='H',等等.

如果我输入"Alas",有没有办法修改下面的代码来吐出我想要的信息.现在,它只适用于该else部分.

int main()
{
    char s[10];

    printf("Yo, this is a string: ");
    gets_s(s);

    if (s == "Alas")
    {
        printf("B ");
    }
    else
    {
        printf("A");
    }

    system("pause");
}
Run Code Online (Sandbox Code Playgroud)

c

0
推荐指数
1
解决办法
68
查看次数

无尽的循环:为什么这个无穷无尽

好的,我在这里遇到了一个小问题.不要介意他们为我提供的代码中的注释.

我的问题在于功能.我希望它进行测试,以确保再次[0] = y或n.如果它不循环,直到我输入正确的数字.

它现在做了什么:它无休止地循环,无论我投入什么.

我确实错过了一些东西吗?

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

//functions called
float wages_loop();

//start main 
int main(void)
{
    char status[10], another[10];
    char buffer[80];

    float wages, other_income, interest, dividends, test;
    int dependents;
    int single_acc = 0, mj_acc = 0, ms_acc = 0, sh_acc = 0;

    printf("Would you like to start: ");
    gets_s(another);

    while (another[0] = 'y')
    {
        //printf("What is your Status: ");
        //gets_s(status);


        wages = wages_loop();



        //printf("\n How much in Other Income. ");
        //gets_s(buffer);
        //other_income = …
Run Code Online (Sandbox Code Playgroud)

c

-1
推荐指数
1
解决办法
136
查看次数

标签 统计

c ×2

c++ ×2

android ×1

arrays ×1

java ×1

vb.net ×1

visual-c++ ×1

xml ×1